Subject: Re: [xsl] xsl:include with plain text input From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Fri, 15 Feb 2002 09:10:47 +0000 |
Hi Peter, > I remember seeing this discussed in an article somewhere, but now I > can't find it. My problem is that I have several plain text files > (*.js, which are ECMAScript scripts) that I would like to output > along with the rest of my stylesheet's output. <xsl:include> > obviously doesn't work, because it expects a stylesheet as input. > Are parsed entities capable of accepting plain text as input? Parsed entities have to be well-formed - they have to follow the same rules as the content of an element. For plain text files, the result of this rule is that any less-than signs or ampersands in the document need to be escaped as they would in an XML file (you need to escape greater-than signs as well if they appear in the sequence ]]>). That usually means that you can't just use a JavaScript script as an external parsed entity, since JavaScript tends to use less-than signs and ampersands quite a lot. Nor can you use the document() function to access such a document -- the document() function only works on well-formed XML documents, so as well as escaping less-than signs and ampersands being escaped, you also need to add a document element wrapped around the text. This is a recognised problem, though. The XSLT 2.0 Working Draft describes an unparsed-text() function that basically works in the same way as the document() function, but allows you to access a plain text document. See http://www.w3.org/TR/xslt20/#function-unparsed-text for details. I don't think that Saxon 7.0 supports this function. Depending on your setup, you might alternatively be able to use XInclude to include information within your XSLT stylesheet. An XInclude processor should be able to take a document and insert the referenced text file in the place of an XInclude element. You could use the XInclude processor either on the stylesheet prior to transformation or on the result following transformation. See http://www.w3.org/TR/xinclude/ for details. Cocoon, for example, has an XInclude Transformer that you could use either on the stylesheet or on the result of the transformation (see http://xml.apache.org/cocoon/userdocs/transformers/xinclude-transformer.html). [I tried looking through the AxKit documentation but didn't find anything about support for XInclude there - glad to be corrected if anyone knows otherwise. You would probably be able to use an XSP page or something similar to achieve the same effect.] Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] xsl:include with plain text i, Peter Davis | Thread | Re: [xsl] xsl:include with plain te, Peter Davis |
Re: [xsl] sort | uniq via keys, Joerg Pietschmann | Date | AW: [xsl] xsl:number, Nestel, Frank ISC 6 |
Month |