2016-01-06 34 views
0

我正在處理將重新映射值的XSLT文件。我能夠處理單個值屬性,但我不知道如何處理具有多個屬性值的節點。在XML文件中的一個節點的實例:具有多個值屬性的XSLT過程XML文件

<saml2:Attribute Name="OfficeLocations" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"> 
    <saml2:AttributeValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">264240</saml2:AttributeValue> 
    <saml2:AttributeValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:type="xs:string">690185</saml2:AttributeValue> 
</saml2:Attribute> 

我需要我的XSLT文件,以輸出以下內容:

<locations> 
    <field name="LocationCode" value="264240"/> 
    <field name="LocationCode" value="690185"/> 
</locations> 
+2

值'LocationCode'應該來自哪裏?附:請發佈一個更完整的例子 - 特別是。 「*處理單值屬性*」的部分。 –

回答

1

您可能正在尋找類似:

<xsl:template match="saml2:Attribute"> 
    <locations> 
     <xsl:for-each select="saml2:AttributeValue"> 
      <field name="LocationCode" value="{.}"/> 
     </xsl:for-each> 
    </locations> 
</xsl:template> 

我說可能,,因爲這個問題缺乏上下文。