Adress text of child code
Posted: Thu Aug 16, 2018 4:30 pm
Hi,
I apply following template and want foo get filled with "bar1" or "bar2". How can I select the value of abc:foo?
Thanks for your help!
I apply following template and want foo get filled with "bar1" or "bar2". How can I select the value of abc:foo?
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:abc="http://example.net/V3.0/ABCSchema" exclude-result-prefixes="abc">
<xsl:template match="/">
<xsl:apply-templates select="//abc:test/abc:vertreter"/>
</xsl:template>
<xsl:template match="//abc:test/abc:vertreter">
<Vertreter>
<xsl:attribute name="foo"><xsl:value-of select="node()/foo/text()"/></xsl:attribute>
<xsl:attribute name="ID"><xsl:value-of select="position()"/></xsl:attribute>
</Vertreter>
</xsl:template>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<abc:test xmlns:abc="http://example.net/V3.0/ABCSchema">
<abc:vertreter>
<abc:foo>bar1</abc:foo>
</abc:vertreter>
<abc:vertreter>
<abc:foo>bar2</abc:foo>
</abc:vertreter>
</abc:test>