Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old June 1st, 2007, 12:43 PM
Registered User
 
Join Date: May 2007
Location: sunnyvale, ca, USA.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multiple xmls and xsls

Hi, I need to use multiple xmls and xsls.
One way which i know is import one of the xsls in the other.
But my doubt is how do i specify that xml1 to be processed by xsl1 and xml2 is to be processed by xsl2.

I use the following approach for processing.
java org.apache.xalan.xslt.Process -in xml1.xml -xsl xsl2.xsl -out greeting2.html.

My xsl2.xsl is as follows

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:import href="xsl1.xsl"/>
<xsl:template match="/">
  <xsl:apply-imports/>
</xsl:template>

</xsl:stylesheet>

But with the above approach, i dont know where to give my xml2.xml for processing.

Can anyone have any inputs, pls update me.
  #2 (permalink)  
Old June 1st, 2007, 06:37 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You don't explain how the different transformations relate to each other. If xml1 is processed using xsl1, and xml2 is processed using xsl2, then why isn't that done by two completely separate transformations?

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
  #3 (permalink)  
Old June 1st, 2007, 09:17 PM
Registered User
 
Join Date: May 2007
Location: sunnyvale, ca, USA.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
Sorry about the confusion.
I need some lines from xml1 and xml2 to be combined in one output html.
Eg.

xml1.xml
<?xml version="1.0"?>
<SOURCE name="store">
    <GROUP hidden="N" name="ReceiptStoreAddress">
        <PARAMETER final="N" hidden="N" name="emailAddress" type="STRING">
            <VALUE value="email_test@group.yahoo.com"/>
        </PARAMETER>
    </GROUP>
    <GROUP hidden="N" name="MINOR">
        <PARAMETER final="N" hidden="N" name="MINOR" type="STRING">
            <VALUE value="RG:36000000000000:36999999999999"/>
        </PARAMETER>
    </GROUP>
 </SOURCE>

xml2.xml

<?xml version="1.0"?>
<tender-line-item>
    <tender-code>CASH</tender-code>
    <line-item-amt>24.94</line-item-amt>
    <line-item-seq-no>2</line-item-seq-no>
    <type-code>TN</type-code>
</tender-line-item>

My output html should have all the lines from both xml1.xml and xml2.xml.
I will be using two different xsls.
Is there any better approach for the same, kindly clarify.
  #4 (permalink)  
Old June 2nd, 2007, 03:04 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

As xsl2.xsl imports xsl1.xsl you effectively have just one XSLT. To operate on more than one document at a time you can have one as your main input and read the other from within the transformation process using the document() function. Alternatively you could read all the files using the document() function and have you main input just specify where they are to be found.

--

Joe (Microsoft MVP - XML)
  #5 (permalink)  
Old June 2nd, 2007, 04:55 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Since there's no overlap between the XML vocabulary used in the two input files you should be able simply to combine the two stylesheets using xsl:include or xsl:import. If there were an overlap, you could use modes.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
  #6 (permalink)  
Old June 4th, 2007, 12:09 PM
Registered User
 
Join Date: May 2007
Location: sunnyvale, ca, USA.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, Am not clear with this.
Am importing one of the xsls, xsl1.xsl in xsl2.xsl.
But how do i specify that xsl1.xsl should be used only for xml1.xml in xsl2.xsl.
Basically, how do i map xsl1.xsl and xml1.xml??
Pls help, am little confused here.
  #7 (permalink)  
Old June 4th, 2007, 01:07 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If the element name SOURCE appears only in xml1, then the template rule

<xsl:template match="SOURCE">

will only ever match an element in xml1, and if tender-line-item only appears in xml2, then

<xsl:template match="tender-line-item">

will only ever match an element in xml2. As I said before, if there were an overlap in the vocabulary of the two files then you could use modes.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference


Similar Threads
Thread Thread Starter Forum Replies Last Post
Grouping xmls sac XSLT 4 July 29th, 2008 04:16 AM
XML element referencing to other xmls alexhinz XSLT 0 February 8th, 2007 09:32 AM
Importing Multiple files in Multiple tables Versi Suomi Access 6 June 1st, 2005 08:47 AM
Multiple ADO multiple user login Oracle9i jhay0721 Pro VB Databases 1 April 4th, 2005 11:23 AM
Updating multiple Rows from multiple fields in ASP vdm_nana SQL Server ASP 0 April 1st, 2004 04:26 AM





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