• Post Reply Bookmark Topic Watch Topic
  • New Topic

Extend XSD to put individual elements instead of using the xs:any in an XSD

 
rasster shib
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:schema targetNamespace="http://uri.abc.org/abc1234/v2.3.4#"

...
...
...
<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>
</xs:schema>


In the above,

<xs:any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded" />

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
 
g tsuji
Ranch Hand
Posts: 696
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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

What you can do is to write your helper xsd's derived from the original xsd that you do not want to edit directly with the latter being included but with some re-modelling. This special kind of xs:include (preserving the same targetNamespace) is called xs:redefine. However, a jump from xs:any to xs:element of specific name living in a namespace other than the one "http://uri.abc.org/abc1234/v2.3.4#" is not a pure restriction or a pure extension. It is a mixture of both. Hence, you write first an xsd with xs:redefine referencing the original xsd via schemaLocation attribute.This xs:redefine takes out xs:any in the type mss:MRegReqType (using xs:restriction). And then you write a second helper xsd with xs:define, this time referencing the newly written xsd as mentioned above. The final xsd's xs:redefine will then use an xs:extension to insert the desired xs:element of its namespace (other than the one prefixed with mss in your code). That is the layout of how it is provisioned and allowed by the w3c schema's grand design conception.




 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!