xsl-list
[Top] [All Lists]

RE: Splitting multiple node occurrences into separate xmls

2005-04-28 14:35:06

I need to do a transformation that will take an input xml 
string in a format 
that is something like
...<a>1</a><a>2</a><a>3</a><a>4</a>...
and apart from transforming it, will split the multiple node 
occurrences for 
"a" into different xml's i.e.
xml[1]=<a>1</a>
xml[2]=<a>2</a>...

XSLT 2.0 solution:

<xsl:template match="a">
  <xsl:result-document href="file{position()}.xml">
    <xsl:copy-of select="."/>
  </xsl:result-document>
</xsl:template>

Some XSLT 1.0 processors have extensions that do similar things.

Michael Kay
http://www.saxonica.com/




I was thnking that if xsl offers some kind of looping 
facility, that may 
help. But then xsl transformation presumably being single-input, 
single-output process, just an xsl maynot by itself suffice. 
Is there a 
possibility that somehow I can have a java loop pass a 
looping variable into 
the xsl-sheet, so that the first transformation gives me the first 
occurrence of "a", and so on.

Another approach could be to let the xsl transformation 
return a single xml 
that has the multiple "a" occurrences and then subsequently 
seperate them 
out by carrying out XPath/DOM operations on the transformed xml.


- Vishwajit.



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--