This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Displaying document( ) output within CDATA


If I understand it right, the file you want to load using document() is XML,
but you want it displayed as if the "<" characters were text rather than
markup, i.e. you want the markup to be visible in the displayed result? An
interesting requirement - it's completely the opposite of what many people
want to do, but entirely legitimate. Most people want to turn "<" characters
into markup, which you can do using disable-output-escaping, but I can't see
any way of doing the reverse.

Really, you want to avoid parsing the example XML in the first place, which
then reduces to the problem of loading a non-XML text file as a string
value. You can do this easily enough with an extension function, or with a
JAXP processor you could write a URIResolver that bypasses the parsing.

Another approach is to write your own serializer (subclassing or pipelining
into the standard one for your chosen processor). Then instead of reading
the example file into the transformation, the transformation can output a
processing instruction containing a reference to the file, and your
serializer can expand this reference by fetching the file and including its
contents.

Mike Kay
Software AG

> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Mark Miller
> Sent: 28 June 2001 05:05
> To: XSL-List@lists.mulberrytech.com
> Subject: [xsl] Displaying document( ) output within CDATA
>
>
> Greetings,
>
> 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.
>
> Thanks,
> Mark
>
>
>
>
>
> __________________________________________________
> 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
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]