[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Add namespaces to a soap xml output

Subject: Re: Add namespaces to a soap xml output
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Fri, 22 Sep 2006 15:58:14 +0200
soap changing namespace
David Carlisle wrote:
I need to change a namaspaces because i need to post this xml in a webservices that recognize only with e namespaces and nillable tag.

Odd, it can't be using a namespace-compliant xml parser then otherwise the prefix would make no difference.

Antoni, since you say that you are new to the subject, perhaps you are mixing the notion of "namespace" and "prefix" here. Many people mix them up when they start with XML + Namespaces. Using XSLT itself as an example, the following two snippets are exactly identical to any processor:


<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:apply-templates match="/" />
</xsl:stylesheet>

<antoni:stylesheet version="1.0"
    xmlns:antoni="http://www.w3.org/1999/XSL/Transform">
 <antoni:apply-templates match="/" />
</antoni:stylesheet>


The example illustrates that the prefix is just a placeholder. When the prefix, as declared in the root tag, is used before a tag in the document, it means that the tag belongs to that namespace. In the second example: "antoni" prefix matches "http://www.w3.org/1999/XSL/Transform" namespace.


Any namespace aware server, and notably SOAP servers in this matter, handle things based on the namespace, not based on the prefix. Changing the prefix effectively does not change the semantics of the XML, it only changes the visual representation to you, the coder. In effect, I've seen parsers (wasn't it MSXML?) that notoriously replaced any namespace with the ns1, ns2, ns3 prefix etc. Which is by definition correct, as long as the namespace it maps to stay the same.

In your output:

<cup:RICHIESTA_INFORMAZIONI_ASSISTITO DataOra="10102005" idCUP="1" idOperatore="DAVIDE" xmlns="some.url" xmlns:cup="some.url">

you specify two namespaces: a default one and a prefixed one. This means that any tag without a prefix still corresponds to the namespace "some.url". Any element with the prefix "cup" will do the same. Thus, the following two elements are equal:

<cup:CodFiscale>TRNCMN78S24F839Y</cup:CodFiscale>
<CodFiscale>TRNCMN78S24F839Y</CodFiscale>

Unless of course, you remove the default namespace.

> webservices that recognize only with e namespaces and nillable tag.
Do you mean with a nillable tag that an element can be set to nil="true"? In that case, you should use the namespace "http://www.w3.org/2001/XMLSchema-instance", which you already do, and, when bound to "xsi" prefix, use xsi:nil="true" for an element that must be nill. You already have this, so you don't need to change anything.


Cheers,
-- Abel Braaksma

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.