Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: Can you embed XML in XSL and access it? >Thread Next - Re: Can you embed XML in XSL and access it? Re: Can you embed XML in XSL and access it?To: NULL Date: 10/1/2006 9:28:00 AM Martin Honnen wrote: > johkar wrote: > > > I would like to embed some XML within my XSL as either a param or a > > global variable. Is this possible? If so, what is the syntax to > > access it? > > You can embed XML data as a top level element (child of the > xsl:stylesheet element) if the element is in a different namespace e.g. > > <xsl:stylesheet > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:data="http://example.com/2006/some-data" > version="1.0"> > > <data:data> > <links xmlns=""> > <link>Link 1</link> > <link>Link 2</link> > </links> > </data:data> > > The XSLT stylesheet itself can be accessed with calling the document > function with '' e.g. > document('') > so you would get at that data with e.g. > document('')/xsl:stylesheet/data:data/links/link > to access all the link elements. > > > If you use xsl:param or xsl:variable and have contents in these elements > then you have a result tree fragment as the parameter or variable value > that you can later copy to the result tree with xsl:copy-of e.g. > > <xsl:call-template name="securetemplate"> > <xsl:with-param name="leftnav"> > <links> > <link>Link 1</link> > <link>Link 2</link> > </links> > </xsl:with-param> > </xsl:call-template> > > <xsl:template name="securetemplate"> > <xsl:param name="leftnav"/> > <xsl:copy-of select="$leftnav"/> > </xsl:template> > One more question. If data:data is on the main page, how can you access it in an included xsl? John | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
