Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with XSLT where source xml document uses default namespace

Have a source xml document that uses namespace containing prefixes and a default namespace. When I transform it using a XSLT doc, the resulting translated xml document is incorrect, that is, element data from the source xml document is missing.

When I remove the "default namespace" from the source xml document, the transformation works as expected.

Question: is there a way to resolve problem without the need to edit out the default namespace from the source xml document? That is, add the solution to the XSLT document.

XML Document:

<MyElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:xsd="http://www.w3.org/2001/XMLSchema"
           xmlns="http://www.zolldata.com/UDX">

where the problem default namespace is xmlns="http://www.zolldata.com/UDX"

like image 672
Larry Avatar asked Aug 27 '09 20:08

Larry


People also ask

What is the use of namespace in XSLT?

In XML a namespace is a collection of names used for elements and attributes. A URI (usually, a URL) is used to identify a particular collection of names.

How do I link XML to XSLT?

Execute an XSLT transformation from an XML fileOpen an XML document in the XML editor. Associate an XSLT style sheet with the XML document. Add an xml-stylesheet processing instruction to the XML document.

Is there any benefit of converting XML to XSLT?

XSLT is commonly used to convert XML to HTML, but can also be used to transform XML documents that comply with one XML schema into documents that comply with another schema. XSLT can also be used to convert XML data into unrelated formats, like comma-delimited text or formatting languages such as troff.

What are the differences between XML XSL and XSLT?

XSLT is an XML-based language that transforms an XML documents and generates output into a different format such as HTML, XHTML or PDF. XSLT is an extension of XSL, which is a stylesheet definition language for XML. XSLT is the most important part of XSL.


1 Answers

Specify same default namespace in XSLT document if your selectors do not use prefixes, or use prefixes for all selectors in the XSLT, but don't forget to bind them to the default namespace of your XML document.

like image 162
Sergey Ilinsky Avatar answered Oct 03 '22 19:10

Sergey Ilinsky