473,320 Members | 1,600 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Missing xmlns attribute while indenting using xalan (JAVA)

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:output 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:output 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?
Jul 20 '05 #1
1 5640


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:output 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:output 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/N...tml#d5360e1276
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: al dav | last post by:
Hi all ok i am not a java programmer I am a sys-admin, my users want xalan and have already got j2sdk_1.4.2 so i have downloaded it and set the CLASS_PATH export...
0
by: bastien | last post by:
Hi all I get an xml file which refer to a xsl file . this xsl refer to others xsl files. I use xalan to do the transformation xml+xsl=>html but we I launch xalan *I get an error: ...
1
by: Fisch von Gestern | last post by:
I have tried to run the extension function/element examples provided with the Xalan-J download. I believe that my classpath is correct, and that my versions are up-to-date. However, I can't get...
2
by: Jon Thackray | last post by:
I'm trying to use the MathML DTD and stylesheets, but get some problems with xmlns attributes. If I do something like <math xmlns="http://..."> .... </math> then xmllint and xalan in...
2
by: Dr. Roger Wießner | last post by:
Hello! I am a newbie to XSLT and need a freeware/GNU Tool to get experience with this new topic. Which one is a good XSLT? Xalan or Saxon, or which one else? Thank you a lot!
1
by: jorgen.wahlund | last post by:
Hi I have problems with transforming a xml document with Xalan and javax.xml.Transformer. Following xsl is used: <xsl:stylesheet version='1.0'...
2
by: VanOrton | last post by:
Hi all, When XercesDOMParser parses an XML document with a Schema instance, by default it adds all missing default and fixed attributes. I have the impression though that it misses the...
0
by: jts2077 | last post by:
I am trying to create a large nested XML object using E4X methods. The problem is the, the XML I am trying to create can only have xmlns set at the top 2 element levels. Such as: <store ...
6
by: John Larson | last post by:
Hi All, I am some information from INSPEC database records in XML to build a relational database of my own. I am currently trying to extract information by doing an XSLT transform of the XML...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.