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: How to escape character when using style sheet parameter in Java


I was trying output the DOCTYPE to the output tree.  The doctype-system
attribute of the
xsl:output provides this functionality.

Thanks for taking your time to reply to my question.

Hien

-----Original Message-----
From: Mike Brown [mailto:mike@skew.org]
Sent: Thursday, May 25, 2000 10:34 PM
To: xsl-list@mulberrytech.com
Subject: Re: How to escape character when using style sheet parameter in
Java


> I trying to use a Java program to perform the transformation and using the
> style sheet parameter to feed in a string into the style sheet from a 
> Java program.  The problem that I encountered is that if a string
> contains XML reserved characters like "<" or ">", the output of the
> transformation translates the "<" into "&lt;"

I do not believe the escaping of markup characters in your output is
related to the fact that you are passing a string as a parameter to the
stylesheet.

Read the section of the XSLT 1.0 spec that deals with output, and you will
see that the default output method is "xml", to produce a well-formed XML
document from the result tree. A well-formed XML document cannot contain
markup delimiters that are not being used to delimit markup, for reasons
that should be obvious. If using the "html" output method, the same
guideline applies. Therefore, when the characters "<" ">" "&" and
sometimes """ or "'" appear in what would be character data sections of
the document, they are escaped.

If you are trying to output XML or HTML, then why do you want to produce
documents that may not be well-formed, with "<" "&" and other markup
characters being treated like ordinary characters, thus making the
document unreadable because there's no way to tell what is markup and
what is not?

However, it was known that there may be some rare occasions when it may be
necessary to disable the escaping of markup characters, so the creators of
the XSLT spec bestowed upon us the disable-output-escaping attribute for
certain situations. Search for this in the spec and you will see how to go
about creating text nodes that, when serialized, will not have their
character data subjected to the usual escape treatment. The caveat is that
using this functionality makes it possible to write broken documents. I
wish the spec used stronger language to discourage its use.

   - Mike
___________________________________________________________
Mike J. Brown, software engineer, Webb Interactive Services
XML/XSL stuff: http://www.skew.org/    http://www.webb.net/


 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]