[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

document() and key() boundaries.

Subject: document() and key() boundaries.
From: <anne.kootstra@xxxxxxxxxxxxx>
Date: Wed, 21 Mar 2007 16:27:57 +0100
 document() and key() boundaries.
Dear experts.

The application I'm working on is one to generate a letter from two xml
files utilising xslt. The base.xml file contains all the information
about the person who the letter is intended for. In the detail.xml
standard text fragments are stored that make up the letter. The xslt
file processes the tags in the base.xml file and grabs the relevant text
fragments from the detail.xml file using the document() function.

The problem I'm facing is that some of the text fragments in the
detail.xml file have a reference to fields in the base.xml document.
However, I've been unable to cross the boundary from detail.xml back
into the base.xml using the key() function. In the included example
there is a text fragment that requires the inclusion of the first name
of the father. The end result is that the name "Klaas" is included,
however I intended to include the name "Bert". The only reason the
father's details are also present in the detail.xml is to prove the fact
that the technique works, but that it searches the wrong document. In
real live this information would not be present in detail.xml.


<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="style.xsl" version="1.0"?>

<?xml version="1.0" encoding="ISO-8859-1"?>


              <paragraph>Parent name is: [<relation type="Father"/>]
[This should be Bert]</paragraph>


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xsl:stylesheet version="1.0"

<xsl:key name="Test_A" match="ContactRelationship"
use="RelationshipType" />

<xsl:template match="/">
       <xsl:call-template name="template"/>

<xsl:template match="paragraph">
       <xsl:apply-templates />

<xsl:template match="relation">
       <xsl:value-of select="key('Test_A',@type)/FirstName"/>

<xsl:template name="template">

                     <xsl:apply-templates select="." />



In the included example I have used two scenarios I've tested and
re-tested. There is one additional thing worth mentioning: the file name
of the base.xml is variable. It is therefore not possible to create a
direct document() link between the detail.xml and the base.xml.
Hopefully someone can help me with this particular situation. It appears
that the focus is locked to the detail.xml document and that is why
"Klaas" is included. Anyone having any suggestions on how to include the
name "Bert"?

The intended version of XSLT is 1.0 however, if 2.0 might be the working
solution I would be curios to know that too. The processor for the job
is at this point msxsl.exe. Which I believe is based upon version 4.0 of

Any and all suggestions are appreciated.

Kind regards,

Anne Kootstra

This message is for the designated recipient only and may contain privileged,
proprietary, or otherwise private information.  If you have received it in
error, please notify the sender immediately and delete the original.  Any
other use of the email by you is prohibited.

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.