Subject: Re: [xsl] Working with multiple files From: RahilQ <qamar_rahil@xxxxxxxxxxx> Date: Fri, 22 Apr 2005 16:10:45 +0100 |
Rahil,
I use the document() function a lot in my stylesheets. You can reference a particular element, or the whole darned thing if you want.
My current project uses the document() function to import into a variable an
XML document which contains meta-data for EDI files (EDI files are flat data
files that defy all logic). I have in my meta-data file each field and the
properties of that field. Such as data type, column width, justification,
and most of all--data source. Then in my XSL stylesheet, I apply templates
to those records and pass into that template the parent element of the data
document.
So if my ascii art isn't too bad, it looks like this:
Data.xml --> format.xsl <-- meta-data.xml | | V
flat-edi.txt
The Data.xml is a pre-defined structure, meaning it will always be in the same format that I expect it to be in. For each record in the meta-data.xml there is a property for where to find the data in the Data.xml file for that record. This allows me to totally separate out the field layouts and the data for my EDI files. This is very easy for me to maintain when the so-called 'standards' change.
Here is how I reference the meta-data.xml document from my format.xsl file:
<xsl:variable name="field_definitions" select="document('837-NSF.field-definitions.xml')/records"/>
And then I just have a template defined in format.xsl that is called like this:
<xsl:apply-templates select="$field_definitions/*[@type = 'AA0']"> <xsl:sort select="field_no" order="ascending" data-type="number"/> <xsl:with-param name="current_context" select="."/> </xsl:apply-templates>
The current_context parameter that I am passing in is the particular element out of the Data.xml document that I am currently processing.
So really I am transforming Data.xml, but using meta-data.xml as a
data-dictionary of sorts.
I'd be happy to go into more detail if anyone is interested. There are a few other things that this design allows me to do that I haven't gone into (but its not really important to the discussion of document function).
Thanks again to everyone on this list who without I would have never made it out of the starting gate. 6 Months ago I didn't even know what XSLT is and now my company's external data reporting depends on it.
--Jim
-----Original Message-----
From: RahilQ [mailto:qamar_rahil@xxxxxxxxxxx] Sent: Friday, April 22, 2005 4:56 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Working with multiple files
Hi Charles
I have used the document() function before but its always been to reference a particular element node rather than the document node.
At this point, Im not entirely sure it'll meet my requirements but I can definitely give it a shot. Ive explained my main requirements in a response to Michael Kay's query.
Thanks Rahil
cknell@xxxxxxxxxx wrote:
The ususal way to include a second (or more) XML file in an XSLT transformation is by using the document() function. Are youunfamiliar
with this function or is it not suitable for some reasonyou haven't
yet explained?
Current Thread |
---|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Working with multiple fil, Jim Neff | Thread | Re: [xsl] working with multiple fil, RahilQ |
Re: [xsl] grouping/position problem, Bruce D'Arcus | Date | [xsl] Exception org.apache.xalan.xs, Belkin, Alla |
Month |