eoglasi
eoglasi

Reputation: 169

One XML, several XML outputs with xslt transformation

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?

Upvotes: 0

Views: 61

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167401

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.

Upvotes: 2

Related Questions