Missing xmlns attribute while indenting using xalan (JAVA)

Discussion in 'XML' started by Hyunchan Kim, Dec 18, 2003.

  1. Hyunchan Kim

    Hyunchan Kim Guest

    To indent xml file, I made an instance of Transformer from Templates
    using following.

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xalan="http://xml.apache.org/xslt"
    version="1.0">
    <xsl:eek:utput method="xml" indent="yes" xalan:indent-amount="4"/>
    <xsl:template match="/">
    <xsl:copy-of select="."/>
    </xsl:template>
    </xsl:stylesheet>

    The transform seems to work fine, most of the cases. But if I call
    transform above XML as an input, output has only one xmlns attribute
    like this.

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet
    xmlns:xalan="http://xml.apache.org/xslt"
    version="1.0">
    <xsl:eek:utput method="xml" indent="yes" xalan:indent-amount="4"/>
    <xsl:template match="/">
    <xsl:copy-of select="."/>
    </xsl:template>
    </xsl:stylesheet>

    Following attribute is lost...
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

    If I modify "xmlns:xsl" to "mlns:xsl" (delete first character to see
    what happens), output is correct i.e, root element has two attributes
    including
    mlns:xsl="http://www.w3.org/1999/XSL/Transform"

    I have read some reference materials to find out what's wrong. But I
    can't find any problem.
    As I know so far, <xsl:template match="/"> means root of DOM tree and
    <xsl:copy-of select="."/> means copy that to target document.

    So, I think everything should go fine...

    Does anyone know what's wrong?
     
    Hyunchan Kim, Dec 18, 2003
    #1
    1. Advertising

  2. Hyunchan Kim wrote:

    > To indent xml file, I made an instance of Transformer from Templates
    > using following.
    >
    > <?xml version="1.0" encoding="UTF-8"?>
    > <xsl:stylesheet
    > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    > xmlns:xalan="http://xml.apache.org/xslt"
    > version="1.0">
    > <xsl:eek:utput method="xml" indent="yes" xalan:indent-amount="4"/>
    > <xsl:template match="/">
    > <xsl:copy-of select="."/>
    > </xsl:template>
    > </xsl:stylesheet>
    >
    > The transform seems to work fine, most of the cases. But if I call
    > transform above XML as an input, output has only one xmlns attribute
    > like this.
    >
    > <?xml version="1.0" encoding="UTF-8"?>
    > <xsl:stylesheet
    > xmlns:xalan="http://xml.apache.org/xslt"
    > version="1.0">
    > <xsl:eek:utput method="xml" indent="yes" xalan:indent-amount="4"/>
    > <xsl:template match="/">
    > <xsl:copy-of select="."/>
    > </xsl:template>
    > </xsl:stylesheet>
    >
    > Following attribute is lost...
    > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    >
    > If I modify "xmlns:xsl" to "mlns:xsl" (delete first character to see
    > what happens), output is correct i.e, root element has two attributes
    > including
    > mlns:xsl="http://www.w3.org/1999/XSL/Transform"
    >
    > I have read some reference materials to find out what's wrong. But I
    > can't find any problem.
    > As I know so far, <xsl:template match="/"> means root of DOM tree and
    > <xsl:copy-of select="."/> means copy that to target document.
    >
    > So, I think everything should go fine...
    >
    > Does anyone know what's wrong?



    Well, the namespace http://www.w3.org/1999/XSL/Transform has to be
    declared in every stylesheet but should not be output normally so it is
    tricky to have it included. I don't have a solution currently, maybe you
    can find something in the XSL FAQ:
    http://www.dpawson.co.uk/xsl/sect2/N5536.html#d5360e1276
    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Dec 18, 2003
    #2
    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. john1001

    Unrecognized attribute 'xmlns'.

    john1001, Oct 14, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    6,108
    Juan T. Llibre
    Oct 15, 2005
  2. kai
    Replies:
    7
    Views:
    2,266
    Steven Cheng[MSFT]
    Nov 21, 2005
  3. cvissy
    Replies:
    0
    Views:
    609
    cvissy
    Nov 16, 2004
  4. Replies:
    0
    Views:
    1,365
  5. afshar
    Replies:
    3
    Views:
    24,320
    aljar
    May 19, 2010
Loading...

Share This Page