473,796 Members | 2,376 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:styleshe et
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:xalan="ht tp://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:styleshe et
xmlns:xalan="ht tp://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 5681


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:styleshe et
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:xalan="ht tp://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:styleshe et
xmlns:xalan="ht tp://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
4031
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 CLASS_PATH=/usr/local/java/xalan-j_2_5_2/bin/xalan.jar:/usr/local/java/xalan -j_2_5_2/bin/xml-apis.jar:/usr/local/java/xalan-j_2_5_2/bin/xercesImpl.jar:/
0
1334
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: (Emplacement inconnu de l'erreur)Erreur XSLT
1
2309
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 past the following error. Any help, please? =========================================================================== C:\xalan>test C:\xalan>REM @echo off
2
1728
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 validating mode both complain that math doesn't have an xmlns attribute. If I leave out the attribute, then the Mathml stylesheet doesn't format the Mathml content using either
2
2111
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
5405
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' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:xalan="http://xml.apache.org/xslt" xmlns:java="java"
2
3674
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 namespace prefices... I'm using Xerces 2.5.0. Here's a document parsed by Xerces:
0
2797
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 xmlns="http://www.store.com/xml/1.1.0.0/impex/catalog"> <product sku="10050-1653" xmlns="http://www.store.com/xml/1.1.0.0/impex/catalog"> <sku>10050-1653</sku> <name xml:lang="x-default">shop's Foie Gras</name> <online>1</online> ...
6
3732
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 files into a tab-separated text file that I want to import into the database. I have run into the following problem: in some documents there are missing elements, for instance the volume and issue number of an article is not there (i.e. it is defined...
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10455
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10228
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10006
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6788
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.