Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Extending the XHTML transitional XSD

From: cmsmcq@---.--- (-. -. ----------------)
To: NULL
Date: 9/6/2006 6:55:00 PM

"Kidogg" <kieranbenton@g...> writes:

> ...
> I've managed to download the XSD for XHTML transitional from
> the W3C and can validate plain XHTML files fine, and can do the
> same with simple XML containing my tags - but I have no idea
> how to proceed and get the .NET parser to validate from either
> of the XSD's?

> Or can I somehow inherit my XSD from the XHTML transitional
> one? I've looked at the xsd:redefine tag but have no idea where
> to start?

Unless you're doing something rather unusual you probably won't
need to use xsd:redefine.  All you need to do is induce the
validator to create a single schema containing (a) the components
you want from the schema for XHTML transitional, and (b) the
components from your schema for your stuff.  Many validators will
take run-time parameters indicating a set of schema documents
they should read and build schema components from; many (most?) 
will automatically read and process any schema document mentioned
in a schemaLocation hint in the XML instance, unless you
explicitly tell them not to do so.  

It probably won't be essential, but it may be convenient to
create a driver file: a single schema document that imports both
the XHTML schema documents you want and your own stuff.  It might
look like this:

   <xsd:schema xmlns:xsd ="http://www.w3.org/2001/XMLSchema" >

    <xsd:annotation>
     <xsd:documentation>
      <div xmlns="http://www.w3.org/1999/xhtml">
       <p>Simple driver file for schema with XHTML and my-stuff.</p>
       <p>Just import what we know we need.  This provides a single
          schema document to start out from.</p>
      </div>
     </xsd:documentation>
    </xsd:annotation>
   
   <xsd:import 
     namespace="http://www.example.com/myschema" 
     schemaLocation="http://www.example.com/myschema.xsd"/>
   
   <xsd:import 
     namespace="http://www.w3.org/199/xhtml"  
     schemaLocation="http://www.example.com/mycache/xhtml-transitional.xsd"/>  
   
   </xsd:schema>

Strictly speaking, the schemaLocation attribute on xsd:import
is a hint, not an instruction; you'll want to consult the
documentation for the validator you're using to see whether
it honors the hint (almost all current schema processors
seems to -- it can be a problem to tell them NOT to do so,
if for some reason you want to prevent it).

Once you succeed in getting the processor to build a schema
with components for both namespaces you're interested in,
you may discover that one or the other of the schema authors
has failed to indicate any place where elements in other
namespaces are legal.  It's been a while since I read the
XHTML schema documents, so I don't remember whether they 
have wildcards for other namespaces at appropriate locations
or not.  If they do, and your stuff does, too, then you're
done.  (From your description, I infer that your declaration
for a template will allow as content any element from the 
XHTML namespace; if it doesn't, either I've misunderstood
your design or you may want to make a change.)

If the XHTML schema documents have no wildcards, then you'll need
to do something about it, to make sure your stuff (e.g. your
membershipcardheader and membershipcardfooter elements) can occur
at appropriate locations in an HTML context.  The easiest way is
to declare your elements as substitutable for appropriate XHTML
elements.

If, for example, membershipcardheader should be able to
appear pretty much wherever the XHTML 'p' element can
appear, then you'd write

  <xsd:element name="membershipcardheader"
               substitutionGroup="xhtml:p"
               ... >
   ...
  </xsd:element>

One concern here is that the type of membershipcardheader
needs to be the same as that of xhtml:p, or derived from
it by extension or restriction.  Be sure you're using the
schema documents from the Modularization of XHTML document,
not the ones intended for stand-alone use in "XHTML 1.0
in XML Schema".

I hope this helps.

--C. M. Sperberg-McQueen
  World Wide Web Consortium





transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent