Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: How do I convert a HTML tag to a XHTML tag in XSL?

From: Peter Flynn <peter.nosp@-.--------.-->
To: NULL
Date: 10/10/2007 10:24:00 PM

Frank Peterson wrote:
> I need to convert the <BR> in the following XML file to <br /> but I
> cant figure out how.

There is no such tag as <BR> in that file.

It's in a CDATA section so it isn't markup: it's just a less-than sign, 
a B, an R, and a greater-than sign.

This is why using CDATA sections for "hiding" or "passing" markup is 
almost always wrong, and the result of insufficient understanding of the 
nature of the problem. See http://xml.silmaril.ie/authors/cdata/

> XML:
[snip]
> <details> <![CDATA[  The couple enjoyed a week-long honeymoon in
> Cancun, Mexico.<BR> And now reside in Los Angeles ]]> </details>

The only way around it now is to write an XSLT template for text() and 
test it recursively for the presence of the string "<BR>", then output 
the substring-before and "<br/>" and pass the the substring-after 
through to the next cycle.

To avoid this in the future, don't allow the creator to embed SGML-style 
EMPTY elements in XML text. Turn them into XML first, and then there is 
no need to use the CDATA. It can be hard when you have to deal with poor 
quality data sources, but that's what pattern-matching stream editors 
are for :-)

///Peter


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent