[xsd-users] multiple namespace prefix problem

Boris Kolpackov boris at codesynthesis.com
Mon Jul 3 13:00:55 EDT 2017


Hing Liu <hing.liu at gmail.com> writes:

> <Address legalAddressType="OECD301"
> xmlns:*p1*=*"http://www.ird.gov.hk/AEOI/aeoitypes/v1
> <http://www.ird.gov.hk/AEOI/aeoitypes/v1>*">
>               <*p1*:CountryCode>AF</p1:CountryCode>
>               <*p1*:AddressFree>
>                 <*p1*:Line>Line1</p1:Line>
>                 <*p1*:Line>Line2</p1:Line>
>                 <*p1*:Line>Line3</p1:Line>
>               </*p1*:AddressFree>
>             </Address>
> 
> I want to remove the "p1" and make it appear like:
> 
> <Address legalAddressType="OECD301">
>               <CountryCode xmlns="*http://www.ird.gov.hk/AEOI/aeoitypes/v1
> <http://www.ird.gov.hk/AEOI/aeoitypes/v1>*">AF</CountryCode>
>               <AddressFree xmlns="*http://www.ird.gov.hk/AEOI/aeoitypes/v1
> <http://www.ird.gov.hk/AEOI/aeoitypes/v1>*">
>                 <Line>Line1</Line>
>                 <Line>Line2</Line>
>                 <Line>Line3</Line>
>               </AddressFree>
>             </Address>

This is not going to be easy to achieve. You will have to serialize
CountryCode and AddressFree separately into DOMElements.

In such situations, the commonly-used approach is to assign a meaningful
prefix to each namespace since when there is more then one, none of them
is really the "default".

Boris



More information about the xsd-users mailing list