I need to transform this structure
<A>
<B>value1</B>
</A>
<A>
<B>value2</B>
</A>
into
<A>
<B>value1<B>
<B>value2<B>
</A>
What is best solution using XSLT-1.0? Thank you!
PS: I tried this code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
<xsl:key name="group_a" match="//A" use="B"/>
<xsl:template match="/Test"> <a-node> <xsl:for-each select="//A"> <b-node>
<xsl:value-of select="//A/B"/> </b-node> </xsl:for-each> </a-node>
</xsl:template>
</xsl:stylesheet>
but it returns only first value:
<?xml version="1.0" encoding="utf-8"?> <a-node mlns:fo="http://www.w3.org/1999/XSL/Format"> <b-node>value1</b-node> <b-node>value1</b-node> </a-node>
but I need:
<?xml version="1.0" encoding="utf-8"?> <a-node xmlns:fo="http://www.w3.org/1999/XSL/Format"> <b-node>value1</b-node> <b-node>value2</b-node> </a-node>
This style-sheet ...
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
<xsl:template match="/">
<A>
<xsl:apply-templates select="*/A/B"/>
</A>
</xsl:template>
<xsl:template match="B">
<B><xsl:value-of select="."/></B>
</xsl:template>
</xsl:stylesheet>
... will transform ...
<root>
<A>
<B>value1</B>
</A>
<A>
<B>value2</B>
</A>
</root>
... into this ...
<A><B>value1</B><B>value2</B></A>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With