• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.




 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic