0

I have straight forward XML formed:

<root> 
<product code="article_1">   some other code </product>
<product code="article_2">  some other code </product> ... and so on... 
</root>

I am trying to put every node into separate xml which would then need to be named accordingly to code value in that product node. So for example first product node in above xml would be in xml named article_1.xml, second would be in xml named article_2.xml ... and so on.

Can this be done with xslt :D and how?

1 Answer 1

2

Any XSLT 2.0 processor like Saxon 9 or AltovaXML or XmlPrime can do that:

<xsl:template match="product">
  <xsl:result-document href="{@code}.xml">
    <xsl:copy-of select="."/>
  </xsl:result-document>
</xsl:template>

Some XSLT 1.0 processors like xsltproc also have extension allowing a similar approach.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, that worked. I came up with similar code, but did not run it trough XSLT 2.0 processor :D thanks a lot, that was perfect 10 answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.