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: Html tags as part of XML elements rendered as text


Erickson, David wrote:
> I use an XSL stylesheet to parse an XML document into html [...] in IE5.
>    <link>&lt;font face=helvetica size=2>&lt;b>this thing
> costs&lt;/b>&lt;br>$219.00&lt;/font></text>

I can't imagine that this would work with <link> being the start tag
and </text> being the end tag.

One of the concepts of XML is well-formedness, and it looks like you
discovered a way to make your XML-that-contains-HTML well-formed by
changing "<" to "&lt;", but in so doing, you lost sight of the
significance of the markup. When you change markup characters to entity or
numeric character references, you are saying "this is not markup anymore;
this is character data, and I want you to treat it like you would any
other non-markup text".

&lt; in the source document *does* become "<" in the source tree and it
can be copied into the result tree as such, but when the result tree is
serialized as XML or HTML, it is escaped again as &lt; because you said
it's just character data, and we wouldn't want to make character data that
could be confused with markup.

You mustn't put arbitrary HTML, which can be non-well-formed, into your
XML. You can, however, use XHTML:

<link><font face="helvetica" size="2"><b>this thing costs</b><br />$219.00</font></link>

...and use xsl:copy-of rather than xsl:value-of to copy the whole thing.

You can use xsl:copy-of if you have installed a newer version of MSXML
than the one that shipped with IE5. See the IE5/MSXML FAQ that Joshua
Allen posted a URL for today, if you don't know what I'm talking about.
Without a current version of MSXML, you'll be running into many more
problems and misunderstandings. If you're stuck with what you've got, you
could do an "identity transform" instead of xsl:copy-of, but this would
still require that you use the XHTML.

You should also stop thinking of the process of creating HTML as a matter
of serially pasting together strings of marked-up text. ASP, PHP, CFML,
JHTML, JSP, and server-side includes are better tools for that job. With
XML, XHTML and XSL/XSLT, you need to be thinking in terms of node trees
that have been derived from XML and from which you can derive XML or HTML
output, but not by specifying the output literally.

   - Mike
____________________________________________________________________
Mike J. Brown, software engineer at         My XML/XSL resources:
webb.net in Denver, Colorado, USA           http://www.skew.org/xml/


 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]