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 January 27th, 2010, 10:33 AM
Authorized User
 
Join Date: Jan 2009
Posts: 36
Thanks: 3
Thanked 0 Times in 0 Posts
Default document function

I have the following 2 files
test1.xml and test2.xml
test1.xml is the input to the xsl.
i'm doing the following
Code:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="source" select="'test2.xml'"/>
<xsl:template match="/">
<TEST>
<xsl:apply-templates select="document($source)//output/loc/rsktyp[@key='ABC']"/></TEST>
</xsl:template>
<xsl:template match="rsktyp[@key='ABC']">
<rsks>
<objectID>0</objectID>
<date><xsl:value-of select="date"/></date>
<value><xsl:value-of select="value1"/></value> <!-- want to get value1 from test1.xml -->
</rsks></xsl:template></xsl:stylesheet>
test1.xml
<return>
<objectID>21288381</objectID>
<branch>UC</branch>
<branchId>6010</branchId>
<rsk>
<type>ABC</type>
<value1>100.00</value1>
</rsk>
</return>
test2.xml
<output>
<loc>
<rsktyp key='ABC'>
<objectId>123456</objectId>
<date>12-02-2010</date>
</rsktyp>
</loc>
</output>


can you tell me how i get value1 from test1.xml ?

thanks
 
Old January 27th, 2010, 10:40 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Easiest way is to define a global variable which you can use to refer to your input document:

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

Then refer to it elsewhere:

<xsl:value-of select="$main//value1"/>
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old January 27th, 2010, 10:45 AM
Authorized User
 
Join Date: Jan 2009
Posts: 36
Thanks: 3
Thanked 0 Times in 0 Posts
Default

thank you for the help.





Similar Threads
Thread Thread Starter Forum Replies Last Post
xslt document function.. maddukuri XSLT 8 May 16th, 2008 06:31 AM
Document Function Atribute bonekrusher XSLT 2 September 26th, 2006 05:44 PM
Another Document ( ) Function Question bonekrusher XSLT 2 August 4th, 2006 10:45 AM
Document ( ) Function bonekrusher XSLT 5 August 4th, 2006 08:01 AM
How to use document() function jacob XSLT 8 November 30th, 2005 08:58 PM





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