6

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"

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I would add the default namespace, xmlns="zolldata.com/UDX", to my XSLT document. How would I bind? what am I binding?
I tried your first suggestion and that does not work. It appears the default namespace MUST be removed from the XML in order for the XSLT to work (or prefixed properly). Like Larry I don't know what you mean by "...don't forget to bind them to the default namespace". I'm assuming this means actually prefix it with "xmlns:z=..." which only works if you are about to change the xml response instead of having to deal with an existing system that validly uses a default namespace.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.