X
Xiaolei Li
first off, i'm a total newbie at this stuff so excuse any wrong usage of
terminology or whatever else.
i have a XSL to transform a Document such that all "text" nodes will
have a "SPAN" inserted around it. the XSL is given below:
<xsl:transform version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="xhtml" omit-xml-declaration="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="text()" priority="2">
<span lx="" ly="" ux="" uy="">
<xsl:copy/>
</span>
</xsl:template>
<xsl:template match="node()">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:transform>
so basically, i parse a HTML page into a Document using nekoHTML and
then run that Document through this XSL. this is all accomplished in
Java (1.4.2_06) using the javax.xml.transform.Transformer class.
this works pretty well on most pages except a few gives it problems.
for example, http://www.netsol.com does not work. i get the following
error:
-------------------------------------------------------------------
javax.xml.transform.TransformerException: org.w3c.dom.DOMException:
NAMESPACE_ERR: An attempt is made to create or change an object in a way
which is incorrect with regard to namespaces.
at
org.apache.xalan.transformer.ClonerToResultTree.cloneToResultTree(ClonerToResultTree.java:268)
at
org.apache.xalan.templates.ElemCopy.execute(ElemCopy.java:155)
at
org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:425)
at
org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:216)
at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2339)
at
org.apache.xalan.templates.ElemCopy.execute(ElemCopy.java:162)
at
org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:425)
at
org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:216)
at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2339)
at
org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2160)
at
org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1213)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:668)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1129)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1107)
at ApplyTextSpan.applyXSL(ApplyTextSpan.java:79)
at ApplyTextSpan.main(ApplyTextSpan.java:40)
Caused by: org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made
to create or change an object in a way which is incorrect with regard to
namespaces.
at
org.apache.xalan.transformer.ResultTreeHandler.flushElem(ResultTreeHandler.java:870)
at
org.apache.xalan.transformer.ResultTreeHandler.flushPending(ResultTreeHandler.java:954)
at
org.apache.xalan.transformer.ResultTreeHandler.startElement(ResultTreeHandler.java:243)
at
org.apache.xalan.transformer.ClonerToResultTree.cloneToResultTree(ClonerToResultTree.java:219)
... 15 more
terminology or whatever else.
i have a XSL to transform a Document such that all "text" nodes will
have a "SPAN" inserted around it. the XSL is given below:
<xsl:transform version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="xhtml" omit-xml-declaration="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="text()" priority="2">
<span lx="" ly="" ux="" uy="">
<xsl:copy/>
</span>
</xsl:template>
<xsl:template match="node()">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:transform>
so basically, i parse a HTML page into a Document using nekoHTML and
then run that Document through this XSL. this is all accomplished in
Java (1.4.2_06) using the javax.xml.transform.Transformer class.
this works pretty well on most pages except a few gives it problems.
for example, http://www.netsol.com does not work. i get the following
error:
-------------------------------------------------------------------
javax.xml.transform.TransformerException: org.w3c.dom.DOMException:
NAMESPACE_ERR: An attempt is made to create or change an object in a way
which is incorrect with regard to namespaces.
at
org.apache.xalan.transformer.ClonerToResultTree.cloneToResultTree(ClonerToResultTree.java:268)
at
org.apache.xalan.templates.ElemCopy.execute(ElemCopy.java:155)
at
org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:425)
at
org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:216)
at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2339)
at
org.apache.xalan.templates.ElemCopy.execute(ElemCopy.java:162)
at
org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:425)
at
org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:216)
at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2339)
at
org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2160)
at
org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1213)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:668)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1129)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1107)
at ApplyTextSpan.applyXSL(ApplyTextSpan.java:79)
at ApplyTextSpan.main(ApplyTextSpan.java:40)
Caused by: org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made
to create or change an object in a way which is incorrect with regard to
namespaces.
at
org.apache.xalan.transformer.ResultTreeHandler.flushElem(ResultTreeHandler.java:870)
at
org.apache.xalan.transformer.ResultTreeHandler.flushPending(ResultTreeHandler.java:954)
at
org.apache.xalan.transformer.ResultTreeHandler.startElement(ResultTreeHandler.java:243)
at
org.apache.xalan.transformer.ClonerToResultTree.cloneToResultTree(ClonerToResultTree.java:219)
... 15 more