Im hoping someone may be able to assist me with transforming one xml file into another xml file. Im new XSLT; so have muddle through the other question/answers to get to a point where I'm almost able to complete the transformation....just need some final assistance.
I have an XML input document :
<copy>
<paragraph>
<name>Letter Text 1</name>
<lastModDate>DD:MM:YY</lastModDate>
</paragraph>
<paragraph>
<name>Letter Text 2</name>
<lastModDate>DD:MM:YY</lastModDate>
</paragraph>
<paragraph>
<name>Letter Text 3</name>
<lastModDate>DD:MM:YY</lastModDate>
</paragraph>
</copy>
What I am trying to do, is condense the tags per paragraph tag into attributes of the paragraph element. Desired output in another xml document to be :
<Paragraph name="Letter Text 1" lastModDate="DD:MM:YY" />
<Paragraph name="Letter Text 2" lastModDate="DD:MM:YY" />
<Paragraph name="Letter Text 3" lastModDate="DD:MM:YY" />
I have my XSL File :
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<Paragraph>
<xsl:for-each select="copy/paragraph">
<xsl:attribute name="name">
<xsl:value-of select="name"/>
</xsl:attribute>
<xsl:attribute name="lastModDate">
<xsl:value-of select="lastModDate"/>
</xsl:attribute>
</xsl:for-each>
</Paragraph>
</xsl:template>
Which gives me an output of this :
<Paragraph name="Letter Text 3" lastModDate="DD:MM:YY" />
Just the last child paragraph node; I've tried moving the tag inside of the for-each tags but throws errors, relating to empty document.
Can someone assist me in recommending the final pieces to my puzzle ?