I have an XSD with an xs:any This allows me to insert any tags/elemnents of my choice. However, I would like to extend this XSD so that instead of using xs:any, I can specify my own specific elements.
I do not want to edit the same XSD but create an extension XSD that adds speeicifies the specific elements I would like to use instead of using xs:any
Here is a part of my XSD.
...
...
...
<xs:element name="MRegReq" type="mss:MRegReqType" />
<xs:complexType name="MRegReqType">
<xs:complexContent>
<xs:extension base="mss:MessageAbstractType">
<xs:sequence>
<xs:element name="User" type="mss:UserType" />
<xs:element name="EData" type="xenc:EDataType"
minOccurs="0" />
<xs:any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
In the above,
is what I would like to replace with an extension, so that when I regenerate the stubs etc using JAX-WS, I can get access to the individual elements specified in the XSD extension (instead of having to get the request.getAny() and iterate through the nodes to get each element).
Any pointers/help would be really appreciated
You cannot replace an element in an extension:
Schema Component Constraint: Derivation Valid (Extension)
If the {derivation method} is extension, the appropriate case among the following must be true:
...
1.2 Its {attribute uses} must be a subset of the {attribute uses} of the complex type definition itself, that is, for every attribute use in the {attribute uses} of the {base type definition}, there must be an attribute use in the {attribute uses} of the complex type definition itself whose {attribute declaration} has the same {name}, {target namespace} and {type definition} as its attribute declaration.
In plain language: An extension must include all elements as the base type with the same name, namespace and type.
But it shouldn't be a problem to create another extension:
<xs:choice>
<xs:element name="MRegReqA" type="mss:MRegReqTypeA" />
<xs:element name="MRegReqB" type="mss:MRegReqTypeB" />
</xs:choice>
<xs:complexType name="MRegReqType">
<xs:complexContent>
<xs:extension base="mss:MessageAbstractType">
<xs:sequence>
<xs:element name="User" type="mss:UserType" />
<xs:element name="EData" type="xenc:EDataType" minOccurs="0" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="MRegReqTypeA">
<xs:complexContent>
<xs:extension base="mss:MRegReqType">
<xs:sequence>
<xs:element name="Product" type="mss:ProductType" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="MRegReqTypeB">
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.