472,804 Members | 1,249 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

XSL xmlns usage problems during transform

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"
xmlns:convert="com.foo.Class">

<xsl:output method="xml"
encoding="UTF-8"
indent="yes"
xalan:indent-amount="2"/>
<and so on with specific transformation>
</xsl:stylesheet>

The xml parsed have the followin format:
<?xml version="1.0" encoding="utf-16"?>
<MessageHeader xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.foo2.com/XMLSchema/Envelope">
<Message xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
messageId="EMI20051026093900046"
xmlns="http://www.foo2.com/Schema.xsd">

<and so on with specific tags>
The problem I have is that the transformation, that earlier worked
fine, has stopped to work. The only differense is the last part of the
given xml. It has changed from:
xmlns=""
to
xmlns="http://www.foo2.com/Schema.xsd"

And the transformation stopps early without transforming the rest of
the document.
Questions:
What does the xmlns field do actually?
Can one override the xmlns field?
Any other solutions?

Remember that the xml given is from a another part and we cant control
the xml sent to us.

Thank you for your help
Jörgen

Oct 26 '05 #1
1 5353


jo************@gmail.com wrote:

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"
xmlns:convert="com.foo.Class"> The xml parsed have the followin format:
<?xml version="1.0" encoding="utf-16"?>
<MessageHeader xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.foo2.com/XMLSchema/Envelope">


The problem is that various elements are in a default namespace defined
with xmlns="namespaceURI" so those elements have a name without a prefix
(e.g. MessageHeader) but are in a certain namespace.
To match that with XPath 1.0 you need to bind a prefix to the default
namespace and use that prefix in XPath expressions and XSLT match
matterns. No change is needed on the XML input but inside of the
stylesheet you need to add e.g.
xmlns:pf1="http://www.foo2.com/XMLSchema/Envelope"
xmlns:pf2="http://www.foo2.com/Schema.xsd"
on the xsl:stylesheet element, then your XPath expressions can look alike
/pf1:MessageHeader/pf2:Message
to select elements in the namespaces bound to the prefixes used.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 26 '05 #2

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

Similar topics

7
by: Rosa Mª Gómez Flores | last post by:
Hallo! I don't understand exactly what is the 'xmlns' attribute, nor why it have problems with the xmlns attribute of the sylesheet, but I need it in my output XML file. Could anybody tell me...
1
by: Hyunchan Kim | last post by:
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"...
3
by: Mike Dickens | last post by:
hi, i'm sure this has come up before but havn't managed to find an answer. if i have the following xslt <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet method="xml" version="1.0"...
11
by: ma740988 | last post by:
I'm perusing a slide with roughly 12 bullets spread across 3 pages. Each bullet reflects 'advice'. I'm ok with all but 1 bullet, more specifically the bullet that states: " Avoid the STL unless...
4
by: David S. Alexander | last post by:
I am trying to transform XML to XML using an XSLT in C#, but the root node of my XML is not being matched by the XSLT if it has an xmlns attribute. Am I handling my namespaces incorrectly? My C#...
7
by: Simon Hart | last post by:
Hi, I have a requirement to remove the xmlns from the DOM in order to pass over to MS CRM 3.0 Fetch method.It seems the fetch method blows up if there is a xmlns present!?! The reason I have a...
0
by: R. Ian Lee | last post by:
I've built an XSLT file that transforms data to SpreadsheetML format. The XSLT uses a <xsl:call-template/to build each worksheet. For some reason, when I transform the file, it is inserting...
2
by: shaun roe | last post by:
I'm trying to follow the recommendations for svg writing at http://jwatt.org/svg/authoring/ and I am generating my svg with xslt. I had some problem with namespaces, and although I think I solved...
6
Dormilich
by: Dormilich | last post by:
Hi, I have some problems removing the xmlns attributes from a transformed xml file. I can't completely remove them (so it would validate). the problematic elements are <div> or the elements...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.