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

Re: xml include

Subject: Re: xml include
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 11 Apr 2001 13:34:26 +0100
xml include xsl

> Thanx, this worked.
> But I inserted the line
>       <xinclude:include href="xml2.xml"/>
> after the first include to xml file and insterted another line
>     <H2><xsl:value-of select="$x//author2"/></H2>
> to xsl. (xml2.xml contains author2). The value of author2 returned is null.
> How can I access second included file ?

It depends a bit what how you want to work. You are using the so called
"pull" method in which you basically have everything in one template and
use value-of to pull in bits of data.

Which processor are you using, because I think that it should have
worked anyway because $x should contain a root node for each included
document, and so value-of select="$x//author2" should give you the
string value of the first ,author2 element in any of those documents
(although you don't have conrol over which document, if you do it like
that)



However the way I would normally do these things is the "push" method 
where you have lots of templates, so in this case

<xsl:stylesheet version='1.0'
    xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
       xmlns:xinclude="http://www.w3.org/1999/XML/xinclude">

    <xsl:output method="html" />

<xsl:template match="document">
 <html>
 <body>
<xsl:apply-templates/>
 </body>
 </html>
</xsl:template>

<xsl:template match="xinclude:include">
  <xsl:apply-templates select="document(@href)"/>
</xsl:template>

<xsl:template match="author">
 <h2><xsl:value-of select="."/></h2>
</xsl:template>

<xsl:template match="title">
 <h1><xsl:value-of select="."/></h1>
</xsl:template>

and so on. just adding templates for whatever you need.
Note that the template for xml include doesn't actually add anything to
the output it just moves the context for the apply-templates over to the
document specified.

David


_____________________________________________________________________
This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit
http://www.star.net.uk/stats.asp

 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.