Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 25th, 2008, 06:04 AM
Authorized User
 
Join Date: Jul 2008
Location: , , .
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multiple input xml / get data from other xml file

Hi,
I am unable to get the Date value. I have multiple input xml file, i am unable to load other xml inbetween such as

<getdata from file1, getdata from file2, again getdata from file1>

[u]Command:</u> $xalan Input.xml fileXSL.xsl

[u]Actual Output: </u> FORMHDR|1.85|Mr.|????????||
[u]Expected Output:</u> FORMHDR|1.85|Mr.|20080428||

Please find the xml and xsl file as follows,

[u]Input.xml:</u>
<?xml version="1.0" encoding="UTF-8"?>
<Envelope>
<Part File='INV24.2302.xml' LinkType='REL' DocType='INV' Format='XML'/>
<Part File='ADDR24.2302.xml' LinkType='REL' DocType='ADD' Format='XML'/>
</Envelope>

[u]INV24.2302.xml:</u>
<?xml version='1.0' encoding="UTF-8"?>
<Document>
<Invoice>
<Date Type="INV" Date="20080428"/>
<Date Type="START" Date="20060101" />
<Date Type="END" Date="20080427" HH="23" MM="59" SS="59" />
</Invoice>
</Document>

[u]ADDR24.2302.xml:</u>
<?xml version='1.0' encoding="UTF-8"?>
<Document Sender="Eureka Communications" Id="080428BA00000000910" BAId="BA0000000091">
<AddressPage xml:lang="EN">
<BillAcc Desc="Nm_24" PayMeth="1Cash" BillMedium="L1PDF" CopyNo="1" State="">
<Customer Id="1.85" SocSecNo="" DrivLicNo=""/>
<Addr Name="" City="Frankfurt" Zip="96745" Country="Germany" Line1="Mr." Line2="Jim Collins" Line3="" Line4="Herriot Street 1" Line5="96745 Frankfurt" Line6="Germany" SortCrit="0000000000000000000000000000000000000000 " />
</BillAcc>
</AddressPage>
</Document>


[u]fileXSL.xsl:</u>
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE stylesheet [
<!ENTITY space "<xsl:text> </xsl:text>">
<!ENTITY tab "<xsl:text>#9;</xsl:text>">
<!ENTITY sep "<xsl:text>|</xsl:text>">
<!ENTITY cr "<xsl:text>
</xsl:text>">
]>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xalan" version="1.0">

<xsl:output method="text"/>

<xsl:template match="/">
    <xsl:for-each select="/Envelope/Part">
            <xsl:apply-templates select="document(@File)/Document/AddressPage/BillAcc" mode="FORMHDR"/>
    </xsl:for-each>
</xsl:template>

<xsl:template match="/Document/AddressPage/BillAcc" mode="FORMHDR">
    <xsl:param name="Sheet"/>
    <xsl:text>FORMHDR</xsl:text>&sep;
    <xsl:value-of select="Customer/@Id"/>&sep;
    <xsl:value-of select="Addr/@Line1"/>&sep;
    <xsl:value-of select="document(@File)/Document/Invoice/Date[@Type='INV']/[u]@Date</u>"/>&sep;
    <xsl:value-of select="Customer/@SocSecNo"/>&sep;
</xsl:template>

</xsl:stylesheet>
Reply With Quote
  #2 (permalink)  
Old July 25th, 2008, 06:23 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

In the section highlighted in red the current context is the BillAcc element. This element does not have @File attribute, therefore your document(@File) method will not load anything.

If you have only two documents to load then define some global variables to load them once:

<xsl:variable name="InvDoc" select="document(/Envelope/Part[@DocType='INV']/@File)"
<xsl:variable name="AddDoc" select="document(/Envelope/Part[@DocType='ADD']/@File)"


/- Sam Judson : Wrox Technical Editor -/
Reply With Quote
  #3 (permalink)  
Old July 25th, 2008, 06:33 AM
Authorized User
 
Join Date: Jul 2008
Location: , , .
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your reply.

I tried , but no luck Sam Judson

    <xsl:value-of select="document(/Envelope/Part/@File)/Document/Invoice/Date[@Type='INV']/@Date"/

I can't define the file in variable... because the filename will be dynamic(auto genearation).
Reply With Quote
  #4 (permalink)  
Old July 25th, 2008, 06:59 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

That still wont work. When you refer to "/" from within the context of the BillAcc element you are traversing that document to its root, i.e. the root of /Document/AddressPage/BillAcc. This xml tree does not have an Envelope element.

If you want to refer to your input document from within another document context then create a global variable like so:

<xsl:variable name="root" select="/"/>

And then refer to this like so:

<xsl:value-of select="document($root/Envelope/Part/@File)"/>

/- Sam Judson : Wrox Technical Editor -/
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB.net, adding XML data to an existing XML file saikoboarder XML 11 April 17th, 2008 04:19 PM
How to ignore namespaces in input xml file hanifa XSLT 2 February 14th, 2007 04:14 AM
One XML to Multiple XML file dineshrout XSLT 3 May 11th, 2006 12:24 PM
xml and xsl templates as input to xslt gives xml rameshnarayan XSLT 5 August 3rd, 2005 01:58 AM
Extract data and create xml for input dhol General .NET 1 February 2nd, 2005 03:01 PM



All times are GMT -4. The time now is 02:18 AM.


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