Subject: Re: [xsl] embed XML island in stylesheet? From: Dan Diebolt <dandiebolt@xxxxxxxxx> Date: Wed, 31 Oct 2001 19:16:55 -0800 (PST) |
David - thanks for your help. I am trying to add a fragment of XML to my stylesheet to avoid loading a ancillary XML document that would conatin some type of lookup information. For simplicity lets just say that during the course of transforming my main XML document I need some lookup capability which for the example can simply be this: 1 -> one 2 -> two 3 -> three 4 -> four Your last mail alluded to having two choices a get a handle on the fragment of lookup XML: 1) stuff the XML lookup fragment into <LookUp:data> and access it with the following XPath: select="document('')/xsl:stylesheet/LookUp:data"/ 2) stuff the lookup fragment into the body of a variable definiton and access it with: select="$var" I know how to do the key definition for the Lookup. I would simply like to work out the details of addressing the XML fragment by each of the two methods. Here is my attempt to put both techniques to work in the same stylesheet: <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:LookUp="Something" version="1.0"> <LookUp:data> <x>1</x><y>one</y> <x>2</x><y>two</y> <x>3</x><y>three</y> <x>4</x><y>four</y> </LookUp:data> <xsl:variable name="var2"> <x>1</x><y>one</y> <x>2</x><y>two</y> <x>3</x><y>three</y> <x>4</x><y>four</y> </xsl:variable> <xsl:template match="/"> <xsl:variable name="var1" select="document('')/xsl:stylesheet/LookUp:data"/> <xsl:for-each select="$var1/x"> (<xsl:value-of select="."/>, <xsl:value-of select="following-sibling::y[1]"/>)<br/> </xsl:for-each> <hr/> <xsl:value-of select="$var2"/> <hr/> <xsl:for-each select="$var2/x"> (<xsl:value-of select="."/>, <xsl:value-of select="following-sibling::y[1]"/>)<br/> </xsl:for-each> </xsl:template> </xsl:stylesheet> Here is the result I obtain: (1,one) (2,two) (3,three) (4,four) ----------------- 1one2two3three4four ----------------- The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. Reference to variable or parameter 'var2' must evaluate to a node list. What is wrong with the second technique? I would like to compare these two techniques on a common bases so the code is somewhat symmetrical. __________________________________________________ Do You Yahoo!? Make a great connection at Yahoo! Personals. http://personals.yahoo.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] embed XML island in style, David Carlisle | Thread | RE: [xsl] embed XML island in style, Chris Bayes |
RE: [xsl] Infinite Loop when trying, Ivan Pedruzzi | Date | [xsl] XSL-FO to Pagemaker, Wayne Davis |
Month |