|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Question about variable-field lookup tables
At 2004-01-12 11:41 -0500, Mir Farooq Ali wrote:
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. Sounds like all you need to do is change your context ... you don't describe the meaning of all your markup, but I hope the following helps. .................... Ken 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:output indent="yes"/> <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></xsl:stylesheet> T:\ftemp>saxon ali.xml ali.xsl <?xml version="1.0" encoding="utf-8"?> <TM> <p c="XXXX"> <p c="YYYY"/> <p c="ZZZZ"/> </p> <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 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








