Subject: Re: [xsl] Scope of xml source, includes, and inline xml From: Karl Stubsjoen <kstubs@xxxxxxxxx> Date: Thu, 31 Mar 2005 13:25:40 -0700 |
So let me pose a simple example. 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"/> Resulting in a match on: foo = 3; and foo = 4 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??? --> <!-- mabye, but isn't /data/foo out of context??? --> <xsl:for-each select="/data/foo"> <xsl:if test=".=current()/."> <!-- I'M ASSUMING WE NEVER MAKE IT HERE --> </xsl:if> </xsl:for-each> </xsl:template> On Thu, 31 Mar 2005 20:55:11 +0100, Michael Kay <mike@xxxxxxxxxxxx> wrote: > > I am discovering such... I think a better approach is to import the > > xml into a variable at the parent level, so into > > parent_xslt_document.xsl > > Would you agree? > > Yes, I would always use global variables for this kind of thing. Or external > "lookup.xml" files, read using the document() function. > > > > Also, since we are on the subject: > > Is there such thing as cross-walking xml sources? Recently I tempted > > to match all (as an example) AAA elements with a value of matching all > > BBB element values where BBB xml Source is not the same as AAA's xml > > source. AAA would be part of the original xml source (not sure how > > you refer to that) where BBB is either an inline XML source "user data > > element" or imported into the stylesheet into a variable, or passed in > > as a parameter. > > I can't work out exactly what process you are describing, but it's certainly > possible to join, compare, or merge data from multiple sources in XSLT. > > Michael Kay > http://www.saxonica.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Scope of xml source, incl, Michael Kay | Thread | Re: [xsl] Scope of xml source, incl, Karl Stubsjoen |
Re: [xsl] Tricky inclusion match, Dimitre Novatchev | Date | [xsl] Combining two node Sets into , Williamson, Chris |
Month |