Re: [xsl] Fw: Converting to different format

Subject: Re: [xsl] Fw: Converting to different format
From: Mike Trotman <mike.trotman@xxxxxxxxxxxxx>
Date: Sun, 22 Aug 2004 11:17:51 +0100
XSLT 1.0 only allows one result document from an XSLT transformation.
There is a (non-core) exslt:document extension element that does create multiple result documents
http://www.exslt.org/exsl/elements/document/index.html
IF your XSLT processor supports it (or something similar).


Saxon (pre v8.0) and Xalan (and others) both have extensions that will produce multiple result documents.

XSLT 2.0 has an <xsl:result-document> element ( http://www.w3.org/TR/xslt20/#result-trees )
which will produce multiple result documents.
XSLT 2.0 is still only a Working Draft - and not yet a full Recommendation.
As far as I know Saxon 8.0 is the only XSLT processor that supports XSLT 2.0.


So - to break your main document up into several sub documents - you are looking at an XML processing problem that XSLT is not designed to address yet.
You will either need to write an XSLT stylesheet that you can pass a parameter to specifying which <record> element you want to process
and process your main document with thsi style sheet many times with different parameter values
OR
use some XML (or other) processing to break you main document into sub documents
and use a transformation to format each of your sub documents.


I haven't posted any code for this as I don't know what you are using for XML / XSL processing.
The W3C description of <xsl:result-document> is pretty clear
so - get Saxon 8.0 and try that.


A partial example of an XSLT 1.0 stylesheet with a parameter for the <record> number would be:
.....
<xsl:param name='record_number' select='0'/>
<!-- '0' is a dummy value that will be superceded by the parameter value you pass to your processor -->


.....

<xsl:template match='/'>
<xsl:apply-templates select='assets/record[$record_number]'/>
</xsl:template>

....


J_Eugene_Bernard/VML/IT/SGCORP/SANMAR@xxxxxxxxxxxxxxx wrote:


Hi all,

Since i have not clearly communicated my problem in my earlier post,
i am reposting my problem with xml file..
I am having an XML file (File 1) as given below.
I need to create an output XML of "N" such files of structure similer to File 2
(where N is number of record Node in the xml file 1. in this case 4 such files)


If anybody posts complete xslt codes will be greatly appreciated.
since i am a newbie to xslt.

------------------------------------------
File 1:
<?xml version="1.0" ?>
<assets>
<record>
<system>1</system> <asset>a001</asset>
<serial>a01</serial>
<make>HP</make>
<vendor>abc</vendor>
</record>


<record>
<system>2</system> <asset>a002</asset>
<serial>a02</serial>
<make>HP</make>
<vendor>abc</vendor>
</record>


<record>
<system>3</system> <asset>a003</asset>
<serial>a03</serial>
<make>HP</make>
<vendor>abc</vendor>
</record>


<record>
<system>4</system> <asset>a004</asset>
<serial>a04</serial>
<make>HP</make>
<vendor>abc</vendor>
</record>
</assets>
--------------------------------------------- File 2:


<?xml version="1.0" ?>
<assets>
<record>
<desc>
system
</desc>
<detail>
1
</detail>

</record>

<record>
<desc>
asset
</desc>
<detail>
a001
</detail>

</record>
<record>
<desc>
serial
</desc>
<detail>
a01
</detail>
</record>
<record>
<desc>
make
</desc>
<detail>
HP
</detail>
</record>
<record>
<desc>
vendor
</desc>
<detail>
abc
</detail>
</record>
</assets>



Regards
Eugene



-- Datalucid Limited 8 Eileen Road South Norwood London SE25 5EJ United Kingdom

/
tel :0208-239-6810
mob: 0794-725-9760
email: mike.trotman@xxxxxxxxxxxxx

UK Co. Reg:   4383635
VAT Reg.:   798 7531 60

/

Current Thread