W3C home > Mailing lists > Public > xmlschema-dev@w3.org > April 2007

Re: extending schema

From: Dhanji R. Prasanna <dhanji@gmail.com>
Date: Mon, 16 Apr 2007 12:07:59 +1000
Message-ID: <aa067ea10704151907x1141683u3854788077065fdc@mail.gmail.com>
To: "noah_mendelsohn@us.ibm.com" <noah_mendelsohn@us.ibm.com>
Cc: xmlschema-dev@w3.org
Thanks very much Noah I appreciate your help.

Dhanji.

On 4/16/07, noah_mendelsohn@us.ibm.com <noah_mendelsohn@us.ibm.com> wrote:
>
> Well, I'm not sure I can give you a detailed answer without seeing your
> specific schema documents, but I can point you in a general direction.
> Taking one aspect of your requirement, your original XML document has
> <body> defined without the new attributes, and the modified one adds the
> attributes.  As you should be aware if you're using the schema language,
> every element is declared with a type, and in your example we can
> reasonably infer that the type of <body> is different in the two cases. Of
> course, you could write two different schemas, each with different
> declarations:
>
>         <element name="body" type="oldtype"/>
>         <element name="body" type="newtype"/>
>
> but you seem to want to keep your original schema document and just add a
> new one.  If your first document defines element as:
>
>         <element name="body" type="oldtype"/>
>
> then you're going to have to find some way of changing the definition of
> oldtype, and that's likely done in a second schema document using
> <xs:redefine>.   Probably something along the lines of:
>
>         <!-- schema document #2>
>         <xs:schema>
>           <xs:redefine>
>           <xsd:complexType name="oldtype">
>             <xsd:complexContent>
>               <xsd:extension base="xsd:all">
>                 <xsd:attribute name="customAttr" type="xsd:string"/>
>                 <xsd:attribute name="another" type="xsd:string"/>
>                </xsd:extension>
>             </xsd:complexContent>
>           </xsd:complexType>
>           </xs:redefine>
>         <xs:schema>
>
>
> There are probably other ways to solve your problem, and almost surely
> other ways to use redefine in this case (perhaps redefining the type of
> the html element to one in which the element declaration of body gives it
> a different named type.  Anyway, my intuition is that redefine is on the
> list of possibilities for you to consider.  Redefine is controversial,
> because it's tricky in certain ways, and in part because implementations
> in early parsers were not all consistent with each other.  Still, it's an
> option to consider I think.
>
> Please note that I will mostly be away from email this week, but perhaps
> others on this list can help you either to refine this idea, or to come up
> with others.
>
> Noah
>
> --------------------------------------
> Noah Mendelsohn
> IBM Corporation
> One Rogers Street
> Cambridge, MA 02142
> 1-617-693-4036
> --------------------------------------
>
>
>
>
>
>
>
>
> "Dhanji R. Prasanna" <dhanji@gmail.com>
> Sent by: xmlschema-dev-request@w3.org
> 04/09/2007 01:38 AM
>
>         To:     xmlschema-dev@w3.org
>         cc:     (bcc: Noah Mendelsohn/Cambridge/IBM)
>         Subject:        extending schema
>
>
> Hello
>
> I am not sure if this is the right list for this question. I apologize if
> it is not (please point me in the right direction!).
>
> My question is about adding attributes to an xml document via an
> additional schema. For example I would like to add to this:
>
> <html   xmlns="http://www.w3.org/1999/xhtml"
>         xml:lang="en" lang="en">
>
>   <body>...etc.
>
> ...a custom schema that allows certain attributes to be defined on body,
> span and so forth. I imagined something like this:
>
> <html   xmlns:my="http://mynamespaceextentions"
>         xmlns=" http://www.w3.org/1999/xhtml"
>         xml:lang="en" lang="en">
>
>   <body my:customAttr="..." my:another="...">
>
>
> I was unable to do this successfully via type substitution (I want all
> elements to be extended):
>
>     <xsd:complexType name="my-component">
>         <xsd:complexContent>
>             <xsd:extension base="xsd:all">
>                 <xsd:attribute name="customAttr" type="xsd:string"/>
>                 <xsd:attribute name="another" type="xsd:string"/>
>             </xsd:extension>
>         </xsd:complexContent>
>     </xsd:complexType>
>
> But obviously I am doing something wrong. Im sure it is the highlighted
> portion. Then again I am not sure if this can be achieved at all with type
> substitution. Is there any way that I can do this by extending ( i.e.
> importing) the xhtml schema directly into my schema perhaps?
>
> Thanks in advance.
>
> Dhanji.
>
>
Received on Monday, 16 April 2007 02:08:05 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:59 GMT