Tony Thompson wrote:
I am using Xalan 2.7.0 and I am having an issue when trying to serialize
an HTML document. Below I have 2 examples of source documents that have
a comment in the style. For both cases, I have the output method set to
"html". In the first case, the serialized document is fine. In the
second case, the comments in the style have been replaced with entity
references. If I change the output to "xml", I get the same results
with the first source document (it breaks). The transformer that is
being used is org.apache.xalan.transformer.TransformerIdentityImpl. Is
there anything I can do to correct this or might it be an issue with the
Xalan transformer?
This is likely an XSLT 1.0 issue with trying to generate XHTML.
Thanks.
Tony
...
Source #2:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
Your document now has elements with a non-null namespace URI. According to
the XSLT 1.0 recommendation, they must be serialized as XML:
http://www.w3.org/TR/xslt#section-HTML-Output-Method
"The html output method should not output an element differently from the
xml output method unless the expanded-name of the element has a null
namespace URI; an element whose expanded-name has a non-null namespace URI
should be output as XML. If the expanded-name of the element has a null
namespace URI, but the local part of the expanded-name is not recognized as
the name of an HTML element, the element should output in the same way as a
non-empty, inline element such as span."
You haven't shown us your stylesheet, so I'm not sure how you're generating
the style element in the result tree. Perhaps if you posted a minimal
stylesheet that illustrates the two different behaviors, someone can
confirm the behavior is correct.
Dave