Kent Wong
Kent Wong

Reputation: 591

Replace XML namespace prefix with full namespace URI value?

To elaborate on the question, can I replace the namespace definitions with the definition?

Is this still well-formed XML? Are they the "same" in the context of, is the second still a well-formed SOAP XML message, like the original.

For example, This is a well-formed SOAP XML message from an Oracle example. I will then make a copy of it but replace the SOAP-ENV attribute with its definition:

<?xml version="1.0" encoding="utf-8" ?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
    <SOAP-ENV:Fault>
        <faultcode>SOAP-ENV:Client</faultcode>
        <faultstring>Message does not have necessary info</faultstring>
        <faultactor>http://gizmos.com/order</faultactor>
        <detail>
        <PO:order xmlns:PO="http://gizmos.com/orders/">
        Quantity element does not have a value</PO:order>
        <PO:confirmation xmlns:PO="http://gizmos.com/confirm">
        Incomplete address: no zip code</PO:confirmation>
        </detail>
    </SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

So SOAP-ENV, which is defined by the quoted definition "http://schemas.xmlsoap.org/soap/envelope/" is replaced.

<?xml version="1.0" encoding="utf-8" ?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<http://schemas.xmlsoap.org/soap/envelope/:Header/>
<http://schemas.xmlsoap.org/soap/envelope/:Body>
    <http://schemas.xmlsoap.org/soap/envelope/:Fault>
        <faultcode>SOAP-ENV:Client</faultcode>
        <faultstring>Message does not have necessary info</faultstring>
        <faultactor>http://gizmos.com/order</faultactor>
        <detail>
        <PO:order xmlns:PO="http://gizmos.com/orders/">
        Quantity element does not have a value</PO:order>
        <PO:confirmation xmlns:PO="http://gizmos.com/confirm">
        Incomplete address: no zip code</PO:confirmation>
        </detail>
    </http://schemas.xmlsoap.org/soap/envelope/:Fault>
</http://schemas.xmlsoap.org/soap/envelope/:Body>
</http://schemas.xmlsoap.org/soap/envelope/:Envelope>

Upvotes: 1

Views: 466

Answers (1)

kjhughes
kjhughes

Reputation: 111726

No, the syntax you've suggested for replacing namespace prefixes with namespace URIs is not well-formed XML. Some software supports something close, though:

<{http://schemas.xmlsoap.org/soap/envelope/}Envelope />

This is commonly referred to as Clark Notation.

Upvotes: 2

Related Questions