Override a type in a schema

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Override a type in a schema

Andrew Welch
Given an element:

<theirs:foo>

and an XSD for the 'theirs' namespace defining foo as xs:string, how
can I override that definition with my own type?  One way is:

<theirs:foo xsi:type="my_type_for_foo">

Is there a 1.0 way to do it without using xsi:type ?


thanks

--
Andrew Welch
http://andrewjwelch.com

Reply | Threaded
Open this post in threaded view
|

Re: Override a type in a schema

Michael Kay
Given a suitable API, you can validate the element against any type you
like.

One such suitable API is the XSLT instruction:

<xsl:copy-of select="theirs:foo" type="my:type"/>

Michael Kay
Saxonica


On 07/03/2012 17:10, Andrew Welch wrote:

> Given an element:
>
> <theirs:foo>
>
> and an XSD for the 'theirs' namespace defining foo as xs:string, how
> can I override that definition with my own type?  One way is:
>
> <theirs:foo xsi:type="my_type_for_foo">
>
> Is there a 1.0 way to do it without using xsi:type ?
>
>
> thanks
>

Reply | Threaded
Open this post in threaded view
|

Re: Override a type in a schema

Andrew Welch
On 7 March 2012 17:29, Michael Kay <[hidden email]> wrote:
> Given a suitable API, you can validate the element against any type you
> like.
>
> One such suitable API is the XSLT instruction:
>
> <xsl:copy-of select="theirs:foo" type="my:type"/>

Ah ok, I was hoping I was missing some way for my.xsd to import
their.xsd and override the type somehow...


--
Andrew Welch
http://andrewjwelch.com

Reply | Threaded
Open this post in threaded view
|

Re: Override a type in a schema

C. M. Sperberg-McQueen-2
In reply to this post by Andrew Welch

On Mar 7, 2012, at 10:10 AM, Andrew Welch wrote:

> Given an element:
>
> <theirs:foo>
>
> and an XSD for the 'theirs' namespace defining foo as xs:string, how
> can I override that definition with my own type?  One way is:
>
> <theirs:foo xsi:type="my_type_for_foo">
>
> Is there a 1.0 way to do it without using xsi:type ?


One way is:  Write your own schema document for the 'theirs'
namespace, assign the type of your choice to 'foo', and point your
software at your schema document for the namespace.  

Plus:  very simple.

Minus: you end up duplicating all of their declarations,
and if they perform maintenance you don't get those fixes.
(Unless you automate the production the schema document
by writing a simple transform to take their schema document
and replace the appropriate element declaration, leaving
everything else as is.)

Plus and/or minus:  if you do it this way, the type you
provide does not need to be either a restriction or an
extension of xs:string.  That's a distinct plus, except in cases
where it's a distinct minus.  And vice versa.  YMMV and
you have been warned.  Void where prohibited by law, etc
etc etc.

hth

--
****************************************************************
* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
* http://www.blackmesatech.com 
* http://cmsmcq.com/mib                 
* http://balisage.net
****************************************************************