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

Re: Scope of xml source, includes, and inline xml

Subject: Re: Scope of xml source, includes, and inline xml
From: Karl Stubsjoen <kstubs@xxxxxxxxx>
Date: Thu, 31 Mar 2005 14:11:15 -0700
inline select
4 was a mistake (follows 3 I guess).
I would have caught the boolean mistake... thanks for catching that
for the sake of the post!

>   <!-- AT THIS POINT..
>         HOW DO WE REFER BACK TO MAIN XML SOURCE??? -->

Ok, 2 responses now say to create a variable of the root source.  I
was going to ask if this was possibly inefficient or if this is not a
preferred workaround but sounds like it is fairly standard practice. 
Would that be a correct assumption?




On Thu, 31 Mar 2005 21:53:13 +0100, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> > The following xml document is our main document, which I still don't
> > have the terminology for.  It might look like:
> >
> > <data>
> >   <foo>1</foo>
> >   <foo>3</foo>
> >   <foo>5</foo>
> >   <foo>2</foo>
> >   <foo>99</foo>
> > </data>
> >
> > Lets say our XSLT creates a global variable "foo_test" and it imports
> > an external data source which looks like:
> >
> > <foo_test>
> >   <foo>3</foo>
> >   <foo>99</foo>
> > </test_foo>
> >
> > Will the following expression work:
> > <xsl:apply-templates select="data/foo = $foo_test//foo"/>
> 
> The expression (data/foo = $foo_test//foo) returns the boolean value true,
> indicating that a match exists. xsl:apply-templates can only be applied to
> nodes, not to booleans.
> 
> If you want to apply templates to all nodes in <data> that have a
> counterpart in <foo_test>, you can use:
> 
> <xsl:apply-templates select="data/foo[. = $foo_test/foo_test/foo]"/>
> >
> > Resulting in a match on:
> > foo = 3; and foo = 4
> 
> Where did you get foo = 4 from?
> >
> >
> > Now, let do the reverse of this and match on all $foot_test foo
> > elements so we have:
> > <xsl:apply-templates select="$foo_test//foo"  mode="my_external_foo"/>
> >
> > And we have the template:
> > <xsl:template match="foo" mode="my_external_foo">
> >   <!-- AT THIS POINT..
> >         HOW DO WE REFER BACK TO MAIN XML SOURCE??? -->
> 
> Assign a global variable to the "main XML source" using
> <xsl:variable name="root" select="/"/>
> 
> 
> Michael Kay
> http://www.saxonica.com/

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.