Subject: [xsl] Re: Displaying document( ) output within CDATA From: Dimitre Novatchev <dnovatchev@xxxxxxxxx> Date: Wed, 27 Jun 2001 22:20:57 -0700 (PDT) |
Mark Miller wrote: > I am creating a stylesheet for tutorials. Code is > displayed as part of each tutorial page. I would like > to insert the actual code using the document() > function so I won't have to cut and paste the > examples. > > I have not been able to figure out a way to include > the code that is output from the document() function > within a CDATA section. > > This template accesses the code file I want to insert > as the example code. Because it is not within a CDATA > section, it is parsed and the output is shown instead > of the raw code. > > <xsl:template match="preformatted"> > > <xsl:variable name="codeSample" > select="document(following::link[2]/@xslInput)"/> > > <div style="text-align:center;">Code Sample</div> > <pre> > <xsl:value-of select="$codeSample"/> > </pre> > </div> > </xsl:template> > > > Any suggestions on how to insert code from an external > file into a CDATA section would be appreciated. Hi Mark, Putting the code into a CDATA section is not the best decision and does not allways work -- e.g. what if the example code has its own CDATA??? And the reason for the specific problem you describe lies in the following: > <pre> > <xsl:value-of select="$codeSample"/> > </pre> In case you use xsl:copy-of, all nodes of $codeSample will be properly copied into the "pre" element. Therefore use: <pre> <xsl:copy-of select="$codeSample"/> </pre> Hope this helped. Cheers, Dimitre Novatchev. __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Displaying document( ) ou, Adam Turoff | Thread | [xsl] Re: Displaying document( ) ou, Mark Miller |
[xsl] Displaying document( ) output, Mark Miller | Date | [xsl] SGML vs XML, SwetaG |
Month |