Subject: Re: [xsl] Generic Lookup (Element Mapping) From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Tue, 07 May 2002 11:23:38 -0400 |
I have been trying to write a generic xslt template to map the element names based on a lookup table.
The lookup xml file has always a subset of the elements and therefore I do not want to hard code the element names.
The output file is a flat xml file in opposite to the input file.
But my main problem is how navigate through the input file in a generic approach. I'm also just a little concern about the overall performance because the input file might be MBs big.
t:\ftemp>type data.xml <?xml version="1.0" encoding="iso-8859-1"?> <project> <aa1> <aa11>aa11_value</aa11> <aa12>aa12_value</aa12> <aa13>aa13_value</aa13> <aa2> <aa21>aa21_value</aa21> <aa22>aa22_value</aa22> <aa3> <aa31>aa31_value</aa31> <aa4> <aa41>aa41_value</aa41> </aa4> </aa3> </aa2> </aa1> </project>
t:\ftemp>type faroukh.xsl <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xslo="junk" version="1.0">
<xsl:key name="parents" match="Map" use="SEname"/> <xsl:key name="children" match="Map" use="concat(SEname,' ',TEname)"/>
<xsl:template match="/"> <xslo:stylesheet version="1.0"> <xslo:output indent="yes"/> <xslo:template match="/project"><!--preserve project element--> <project> <xslo:apply-templates/> </project> </xslo:template> <xslo:template match="*"/><!--throw away unmapped--> <xslo:template match="text()"/><!--only keep explicitly copied text--> <xsl:apply-templates/> </xslo:stylesheet> </xsl:template>
t:\ftemp>type faroukh.out <?xml version="1.0" encoding="utf-8"?> <project> <aa_1> <aa_11>aa11_value</aa_11> <aa_12>aa12_value</aa_12> </aa_1> <aa_1A> <aa_13>aa13_value</aa_13> </aa_1A> <aa_2> <aa_21>aa21_value</aa_21> </aa_2> <aa_3> <aa_31>aa31_value</aa_31> </aa_3> </project> t:\ftemp>rem Done!
-- Upcoming: 3-days XSLT/XPath and/or 2-days XSLFO: June 17-21, 2002 - : 3-days XML Information Modeling: July 31-August 2, 2002
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995) ISBN 0-13-065196-6 Definitive XSLT and XPath ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-07-1 Practical Formatting Using XSLFO XSL/XML/DSSSL/SGML/OmniMark services, books(electronic, printed), articles, training(instructor-live,Internet-live,web/CD,licensed) Next public training: 2002-05-06,07,09,10,13,15,20, - 06-04,07,10,11,13,14,17,20,07-31,08-05,27,30
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Generic Lookup (Element Mappi, Faroukh Fekravar | Thread | RE: [xsl] Generic Lookup (Element M, Faroukh Fekravar |
Re: [xsl] Identifying two tags that, David Carlisle | Date | Re: [xsl] rotate text 90 degrees, G. Ken Holman |
Month |