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

Accessing multiple documents

Subject: Accessing multiple documents
From: Peter Paulus <paulus@xxxxxxxx>
Date: Mon, 31 Jul 2000 11:38:04 +0200
document binder
Hello XSL-developer,

On trying to access multiple documents from XSLT I ran into a problem, I
can't seem to resolve. (My knowledge of XSLT is very deep, so that may be
the problem in itself).

>From one XML-document (Collate.xml) I want to access a second to retrieve
the name of an element (Bind.xml) and a third document to retrieve the
content of this element (EZ722.xml).

For the sake of clarity I've stripped most parts of the XML-documents that
do not matter.

Here's my primary document: Collate.xml
<?xml version='1.0'?>

<collate content='EZ722.xml' binder='Bind.xml'/>

The second document is: Bind.xml
<?xml version='1.0' encoding='ISO-8859-1'?>

<bind:binding xmlns:bind='urn:NPS-layoutBinder'
xmlns='urn:NPS-layoutBinder'>
<bind><content element='reis/code'/></bind>
<bind><content element='reis/titel[@nivo=1]'/></bind>
</bind:binding>

The third document is: EZ722.xml
<?xml version='1.0' encoding='US-ASCII'?>
<!-- Neroc Publishing Solutions, 20000725 -->
<!DOCTYPE reis SYSTEM "reis.dtd">

<reis type='rondreis'>
<code>EZ722</code>
<titel nivo='1'>14 dagen The Deep South</titel>
<titel nivo='2'>Rondreis door het historische zuiden van Amerika</titel>
</reis>

This is the XSLT transformation stylesheet: Collate.xsl
<?xml version='1.0'?>
<xsl:transform version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
  xmlns:Binder='urn:NPS-layoutBinder'>
<xsl:output method='xml' omit-xml-declaration='yes' media-type='text/xml'/>

<xsl:template match='/'>
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match='collate'>
  *** Hardcoded goal ***
  <xsl:value-of select='document("EZ722.xml")/reis/code'/>
  
  *** Scenario 1: ***
  <xsl:value-of select='document(@content)/reis/code'/>
  
  *** Scenario 2:
  <xsl:variable name='element'
select='document(@binder)/Binder:binding/Binder:bind[1]/Binder:content/@elem
ent'/>
  Content element to retrieve: <xsl:value-of select='$element'/>
  Content of this element: <xsl:value-of
select='document("EZ722.xml")/$element'/>
  
  <!-- 
  Xalan: 
  _exceptionOccurred: org.apache.xalan.xslt.XSLProcessorException (pattern =
'document("EZ722.xml")/$element'
  Extra illegal tokens: 'element')
  
  XT:
  xt: file:/E:/NT_SER~1/XML.Collate.xsl:20 expected node test
  -->
  
  *** Scenario 3:  ***
  <xsl:variable name='element'
select='document(@binder)/Binder:binding/Binder:bind[1]/Binder:content/@elem
ent'/>
  Content element to retrieve: <xsl:value-of select='$element'/>
  Content of this element: <xsl:value-of
select='document(@content)/$element'/>
  
  <!--
  Xalan: 
  _exceptionOccurred: org.apache.xalan.xslt.XSLProcessorException (pattern =
'document(@content)/$element'
  Extra illegal tokens: 'element')
  
  XT:
  xt: file:/E:/NT_SER~1/XML.Collate.xsl:34 expected node test
  -->
  
  *** Scenario 4: ***
  <xsl:variable name='content'>document("<xsl:value-of
select='@content'/>")/<xsl:value-of
select='document(@binder)/Binder:binding/Binder:bind[1]/Binder:content/@elem
ent'/></xsl:variable>
  <xsl:copy-of select='$content'/>

  *** Scenario 5: ***
  <xsl:variable name='content'><xsl:value-of
select='@content'/>/<xsl:value-of
select='document(@binder)/Binder:binding/Binder:bind[1]/Binder:content/@elem
ent'/></xsl:variable>
  <xsl:copy-of select='document($content)'/>

</xsl:template>

</xsl:transform>


My hardcoded goal is displaying element reis/code from EX722.xml. This work,
but is not flexible enough for my application.

I've tried several scenario's to resolve this problem.

Scenario 1 show that I can have a variable 'content'-document. This is one
level of indirection and work. But it still is not flexible enough.

Scenario 2 show that I try to retrieve a variable element form a fixed
document. This does not work. (And wouldn't be flexible enough)

Scenario 3 show that I try to retrieve a variable element from a variable
document. This does not work, but would give me the flexibility I'm looking
for.

Scenario 4 show that I first build up the name of the element from it's
parts and then try to access it. This does not work. It merely displays the
name I've build up.

Scenario 5 try to build up a name from the variable parts and pass that to
the document() function. I'm unsure of what the XSLT specification means
with the URN. I've tried things like 'EZ722.xml#reis/code',
'EX722.xml/reis/code'. Couldn't get this to work.

Any help on this is welcome.

With kind regards,
Peter Paulus

 



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.