<?xml version="1.0" encoding="UTF-8"?>
<p:transformOutput xmlns:p="http://cfpe/export/objects">
<p:objectSet>
<p:objects>
<p:object>
<p:objectAttributes>
<p:objectType>a</p:objectType>
<p:attribute name="x">F600</p:attribute>
<p:attribute name="y">A100</p:attribute>
<p:attribute name="z">D400</p:attribute>
</p:objectAttributes>
</p:object>
<p:object>
<p:objectAttributes>
<p:objectType>b</p:objectType>
<p:attribute name="x">F600</p:attribute>
<p:attribute name="y">C300</p:attribute>
<p:attribute name="z">B200</p:attribute>
</p:objectAttributes>
</p:object>
<p:object>
<p:objectAttributes>
<p:objectType>b</p:objectType>
<p:attribute name="x">a</p:attribute>
<p:attribute name="y">A100</p:attribute>
<p:attribute name="z">B200</p:attribute>
</p:objectAttributes>
</p:object>
</p:objects>
</p:objectSet>
<ns1:Templates>
<ns1:Template>
<ns1:System_Class>a</ns1:System_Class>
<ns1:System_Table>A100</ns1:System_Table>
<ns1:System_Attribute>aA</ns1:System_Attribute>
</ns1:Template>
<ns1:Template>
<ns1:System_Class>b</ns1:System_Class>
<ns1:System_Table>B200</ns1:System_Table>
<ns1:System_Attribute>bB</ns1:System_Attribute>
</ns1:Template>
</ns1:Templates>
XSL我無法從XML輸入
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:p="http://cfpe/export/objects" xmlns:ns1="http://cfpe/export/objects"
exclude-result-prefixes="p">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/p:transformOutput">
<objects>
<xsl:for-each select="p:transformOutput/p:objectSet/p:objects/p:object">
<object type="{p:objectAttributes/p:objectType}">
<xsl:variable name="attributes" select="p:objectAttributes/*" />
<xsl:variable name="matching-template" select="p:transformOutput/ns1:Templates/ns1:Template[ns1:System_Class=$attributes and ns1:System_Table=$attributes]" />
<template>
<xsl:value-of select="tns:System_Attribute"/>
</template>
</object>
</xsl:for-each>
</objects>
</xsl:template>
</xsl:stylesheet>
匹配模板檢索XML attrubutes似乎並沒有找到該值路徑。我是想,如果存在objectAttributes比較System_Class並獲得System_Attribute從如果System_Attribute的價值並不在objectAttributes存在
[XSL標記化的XML輸入文件codition屬性(可能重複http://stackoverflow.com/questions/25921099/xsl-tokenize-the-codition-attribute-with-xml-input-file) – 2014-09-21 09:11:51
它仍然不會放任何東西 – user3983344 2014-09-21 15:39:07
順便說一下,您輸入的XML格式不正確。它缺少一個關閉'p:transformOutput'標記,並且也缺少'ns1'前綴的名稱空間聲明。如果您修改了您的問題以修復XML,這將有所幫助。謝謝。 – 2014-09-21 18:08:11