Subject: RE: [xsl] Accessing the main document from a document() From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Fri, 19 Aug 2005 14:02:01 +0100 |
First, declare a global variable <xsl:variable name="main" select="/"/> Then you can use filter expressions such as $main/data/value[@name=current()/@name] when the context node is a parameter. If the main document is large, then using keys is more efficient. In XSLT 2.0: <xsl:key name="k" match="data/value" use="@name"/> then (again from a parameter element) key('k', @name, $main) to do the join. In 1.0 you have to circumlocute: <xsl:variable name="keyval" select="@name"/> <xsl:for-each select="$main"> ... select="key('k', $keyval)" </ because key() always selects in the current document. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Hans H|bner [mailto:hans.huebner@xxxxxxxxx] > Sent: 19 August 2005 13:20 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] Accessing the main document from a document() > > Hi, > > I am trying to write an XSL stylesheet that displays the data of the > document it is attached to under the control of a second document. > This second document describes the formatting and data types of the > data in the main document. It also defines the order in which the > fields from the main document are displayed. > > Main document: > > <?xml-stylesheet type="text/xsl" href="stylesheet.xsl" ?> > <data device-type="foo"> > <value name="a">blah</value> > <value name="b">blub</value> > </data> > > Formatting document: > > <definitions> > <device type="foo"> > <parameter name="b">... formatting instructions for field > b..</parameter> > <parameter name="a">... formatting instructions for field > a...</parameter> > </device> > <device ... more devices> > </device> > </definitions> > > From the style sheet, I am now selecting the right device definition > and iterate through it's parameters, generating output on the way. > For each of the parameters, I now need access to its value as set in > the main document. How do I do that? > > Thanks in advance! > Hans
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Accessing database, Michael Kay | Thread | RE: [xsl] Accessing database, cknell |
[xsl] DocBook Website --> Silva, Piotr Kopszak | Date | [xsl] Creation of DTD, Verakso |
Month |