[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Working with multiple files

Subject: RE: Working with multiple files
From: "Jim Neff" <jneff@xxxxxxxxxxxxxxx>
Date: Fri, 22 Apr 2005 09:35:07 -0400
multiple xsl files
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:  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 you 
> unfamiliar 
> > with this function or is it not suitable for some reason 
> you haven't 
> > yet explained?

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.