XSL transform error

Discussion in 'Java' started by Xiaolei Li, Jan 24, 2005.

  1. Xiaolei Li

    Xiaolei Li Guest

    first off, i'm a total newbie at this XSL 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">
    <xsl:eek:utput 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. the
    code is something like this:

    Transformer transformer = tf.newTransformer(xslTrans);
    transformer.setOutputProperty(OutputKeys.ENCODING,"latin1");
    transformer.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS,"options");
    transformer.transform(input, output)

    where input and output are Documents. 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
    ---------

    i'm also using xerces 2.6.2 along with neko 0.9.4. can someone perhaps
    shed some light on this error? thank you very much.

    --
    Xiaolei Li | | www.xiaolei.org
    Xiaolei Li, Jan 24, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KathyB
    Replies:
    0
    Views:
    1,004
    KathyB
    Jun 25, 2003
  2. Cowboy \(Gregory A. Beamer\)

    Re: How do i transform an xml with 2 xsl files?

    Cowboy \(Gregory A. Beamer\), Jul 3, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    297
    Showjumper
    Jul 3, 2003
  3. Kevin Flood
    Replies:
    0
    Views:
    1,011
    Kevin Flood
    Sep 8, 2004
  4. Kevin Flood
    Replies:
    1
    Views:
    2,719
    Kevin Flood
    Sep 13, 2004
  5. Replies:
    1
    Views:
    3,591
    A. Bolmarcich
    May 27, 2005
Loading...

Share This Page