Transform error in Java

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

  1. Xiaolei Li

    Xiaolei Li Guest

    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">
    <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.

    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
    ---------

    maybe the error is in the java stuff i have, but as far as the XSL file
    i posted above, does it look correct? 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. CABA
    Replies:
    1
    Views:
    2,280
    Gordon Beaton
    Sep 1, 2003
  2. Matt
    Replies:
    7
    Views:
    18,953
    Andrew Thompson
    May 19, 2004
  3. Angus Parvis
    Replies:
    0
    Views:
    601
    Angus Parvis
    Aug 26, 2004
  4. Replies:
    0
    Views:
    374
  5. JTL.zheng

    How could I transform java to .exe

    JTL.zheng, Dec 5, 2006, in forum: Java
    Replies:
    8
    Views:
    348
    northerntechie
    Dec 6, 2006
Loading...

Share This Page