问题描述:

I want to modify my XSD to suit the corresponding XML file (Test_1.xml). The point here is that in XML I am encountering an attribute (name of attribute is "type") with xsi namespace... But I don't know how to specify the namespace separately for an attribute in schema defination?

Code extract:

<ns:return xsi:type="ax261:StatisticsReturnWS"

xmlns:ax259="http://ws.transverse.ese.esepa.soprabanking.com/xsd"

xmlns:ax263="http://error.transverse.ese.esepa.soprabanking.com/xsd"

xmlns:ax262="http://retour.socle.ws.ese.esepa.soprabanking.com/xsd"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:ax261="http://retour.ws.ese.esepa.soprabanking.com/xsd">

<ax262:returnCode>0</ax262:returnCode>

<ax261:statisticMessageWS **xsi:type="ax261:StatisticMessageWS"**>

网友答案:

The xsi:type attribute does not need to be explicitly declared in your schema: it is declared implicitly and is allowed for every element.

If it were some other namespaced attribute, e.g. xlink:href or xml:id, then you would need to create (or obtain) a schema document for the relevant namespace (xlink or xml), ensure that it contains a global attribute declaration for this attribute, import that schema document into your "main" schema document, bind a prefix to the relevant namespace URI, and then reference the attribute in your complex type definition, e.g. as

<xs:attribute ref="xlink:href"/>
相关阅读:
Top