|
Subject: Re: [xsl] Question about variable-field lookup tables From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 12 Jan 2004 12:07:21 -0500 |
I need some help with a particular problem I'm trying to solve. I need to transform an xml document that is based partially on information that is extracted from another xml file whose purpose is to act like a lookup table.
T:\ftemp>type ali-lookup.xml
<AB>
<TC name="a">
<TTM type="b">
<UCM preference="1">
<UC>S</UC>
<UPS>
<pa prefnum="1">
<XXXX>
<YYYY/>
<ZZZZ/>
</XXXX>
</pa>
<pa prefnum="2">
<WWWW/>
</pa>
</UPS>
</UCM>
</TTM>
</TC>
...
</AB>T:\ftemp>type ali.xml
<TM>
<T id="something" TC="a">
<Type>b</Type>
<Prefs>
<UC>S</UC>
<UPS>1</UPS>
</Prefs>
</T>
<T id="something" TC="a">
<Type>b</Type>
<Prefs>
<UC>S</UC>
<UPS>2</UPS>
</Prefs>
</T>
...
</TM>T:\ftemp>type ali.xsl <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="T">
<xsl:variable name="tc" select="@TC"/>
<xsl:variable name="ttm" select="Type"/>
<xsl:variable name="uc" select="Prefs/UC"/>
<xsl:variable name="ups" select="Prefs/UPS"/>
<xsl:for-each select="document('ali-lookup.xml')">
<xsl:apply-templates mode="modify"
select="/AB/TC[@name=$tc]/TTM[@type=$ttm]/
UCM[UC=$uc]/UPS/pa[@prefnum=$ups]/*"/>
</xsl:for-each>
</xsl:template><xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template><xsl:template match="*" mode="modify" priority="2">
<p c="{name(.)}">
<xsl:apply-templates mode="modify"/>
</p>
</xsl:template><xsl:template match="@*|node()" mode="modify">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>T:\ftemp>saxon ali.xml ali.xsl <?xml version="1.0" encoding="utf-8"?> <TM>
<p c="WWWW"/>
...
</TM>
T:\ftemp>rem-- North America (Washington, DC): 3-day XSLT/2-day XSL-FO 2004-03-15 Instructor-led on-site corporate, government & user group training for XSLT and XSL-FO world-wide: please contact us for the details
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 (F:-0995) ISBN 0-13-065196-6 Definitive XSLT and XPath ISBN 0-13-140374-5 Definitive XSL-FO ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-11-X Practical Formatting Using XSL-FO Member of the XML Guild of Practitioners: http://XMLGuild.info Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Question about variable-f, David Carlisle | Thread | Re: [xsl] Question about variable-f, Mir Farooq Ali |
| Re: [xsl] Question about variable-f, David Carlisle | Date | RE: [xsl] Merging two xml files usi, Bhaskar Reddy |
| Month |