xml - change xmlns value per element in xmlns -


i ask how xmlns attribute can added element on xsd.

the output should similar this:

<?xml version="1.0" encoding="utf-8" standalone="yes"?> <asn>     <itemcode id="itm0002212">         <serialno xmlns="1231123321231600000">             <msn/>             <msisdn>123456789</msisdn>         </serialno>                      <serialno xmlns="1231123321231700000">             <msn/>             <msisdn>123456788</msisdn>         </serialno>         <serialno xmlns="1231123321231800000">             <msn/>             <msisdn>123456787</msisdn>         </serialno>         <serialno xmlns="1231123321231900000">             <msn/>             <msisdn>123456786</msisdn>         </serialno>     </itemcode> </asn> 

i tried use following xsd below application not allow attribute xmlns:

<?xml version="1.0" encoding="utf-8" standalone="yes"?> <xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema" elementformdefault="qualified"> <xs:element name="asn">     <xs:complextype>         <xs:sequence>             <xs:element name="itemcode">                 <xs:complextype>                     <xs:sequence>                         <xs:element name="serialno">                             <xs:complextype>                                 <xs:sequence>                                     <element name="nac" type="xs:string" />                                     <element name="msisdn" type="xs:string" />                                 </xs:sequence>                                 <attribute name="xmlns" type="xs:string"/>                             </xs:complextype>                         </xs:element>                     </xs:sequence>                     <xs:attribute name="id" type="xs:string"/>                 </xs:complextype>             </xs:element>         </xs:sequence>     </xs:complextype> </xs:element> 

thanks, ryan

xmlns attributes not attributes. resolved xml parser declare default namespace in serialno, msn , msisdn live. hence, xml schema not see them in form of attributes. in general, xml forbids , reserves attribute names begin xml in combination of case.

however, looking @ xml document provided, values associated xmlns not uri references, , each serialno has own xmlns value, uncommon: 1 have provide separate schema file each 1 of these namespaces. may point out these or should id fields or custom fields rather xmlns fields.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -