0
votes

I'm working on an XSLT file that will remap values. I am able to handle single value attributes, but I'm not sure how to handle a node that has multiple attribute values. Example of a node in an XML file:

<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>

I need my XSLT file to output the following:

<locations>
    <field name="LocationCode" value="264240"/>
    <field name="LocationCode" value="690185"/>
</locations>
1
Where is the value LocationCode supposed to come from? P.S. Please post a more complete example - esp. the part where you"handle single value attributes". - michael.hor257k

1 Answers

1
votes

You are probably looking for something like:

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

I say probably, because the question lacks context.