Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 22nd, 2004, 03:31 PM
Registered User
 
Join Date: Jun 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multiple XML File Problem

I would like to limit the output of one XML file based on another XML file through styling.
The most basic example would be:

XML Main
<root>
<sale1>
    <company_name>ABC corp</company_name>
    <company_addr>123 East Main</company_addr>
    <company_addr_city>123 East Main</company_addr_city>
    <company_addr_state>123 East Main</company_addr_state>
    <company_addr_zip>123 East Main</company_addr_zip>
    <last_sale>100,000</last_sale>
    <last_sale_year>2004</last_sale_year>
    <last_sale_month>06</last_sale_month>
</sale1>
</root>

XML Limiter
<root>
<limiter>
    <company_name/>
    <last_sale/>
    <last_sale_month/>
</limiter>
</root>

So looping though XML Main, I only want to output the columns that exist in XML Limiter. XML Limiter is dynamically generated, and will change with every submission. So I cannot hard code the value but must loop through both. There will be multiple base lever <sale> record to process through each one outputing the columns as listed in XML Limiter.

I have tried document(), key(), etc to accomplish. I can loop through both, access both pieces indepentantly, but CANNOT build an xpath statement to extract from XML Main based on an element in XML Limiter.

Thanks in advance.
 
Old July 7th, 2004, 05:01 AM
Authorized User
 
Join Date: Jul 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to NotesSensei Send a message via Yahoo to NotesSensei
Default

Hi Jhunsake,
you need to loop through the limiter document and extract the name(). Put that stuff in a variable and call a template using the document function.
Build a reference to your sale.xml on top:
<xsl:variable name="param-top" select="document('sales.xml')/root/sale1"/>

Do a call template inside the loop through the limiter:
<xsl:apply-templates select="$param-top">
     <xsl:with-param name="curParam" select="name()"/>
</xsl:apply-templates>

<xsl:template match="sale1">
 <xsl:param name="curNode"/>
 <xsl:value-of select="*[name()=$curNode]"/> .... or other stuff here...
</xsl:template>

This could do the trick. You need to switch context and the apply-template does that.
Hth
;) stw

If you think education is expensive - try ignorance!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple input xml / get data from other xml file elayaraja.s XSLT 3 July 25th, 2008 06:59 AM
Multiple file upload problem suchita_sindhu .NET Framework 1.x 0 September 8th, 2006 03:06 AM
One XML to Multiple XML file dineshrout XSLT 3 May 11th, 2006 12:24 PM
grouping multiple xml files in one file bcogney XSLT 3 April 21st, 2006 03:58 AM
Problem to create an xml file from two xml files saurabh_inblore XSLT 1 April 12th, 2006 02:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.