Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: How to use DTD and Schema in the single XML file?

From: "Michael Kay" <mike@--------.--->
To: "'Philippe Poulard'" <Philippe.Poulard@------.-----.-->
Date: 7/26/2006 4:37:00 PM

This is one reason I proposed a flatter schema than the one you quote.

At one stage the XSLT/XQuery specs had a mechanism for referencing
non-global element or type definitions, but we decided to take it out,
partly because it was very poorly specified and difficult to fix (for
example, it wasn't clear how named groups affected things), and partly
because it was felt that an addressing mechanism for non-global =
components
ought to come from the Schema WG itself.

For the moment, in XSLT you can validate against a global element =
definition
or a global type. In XQuery you can only validate against a global =
element
definition. (I added validation against a global type as an extension in
Saxon XQuery because one of my users was heavily using FpML, which IIRC =
has
only one global element definition but lots of global types).

Saxon will allow you to validate against a non-global type using the =
Java
API, but you'll have to grovel around the Javadoc to work out how to do =
it.

Michael Kay
http://www.saxonica.com/
 

> -----Original Message-----
> From: Philippe Poulard [mailto:Philippe.Poulard@s...] 
> Sent: 26 July 2006 14:47
> To: Michael Kay
> Cc: 'Balakrishnan'; 'Mukul Gandhi'; xmlschema-dev@w...
> Subject: Re: How to use DTD and Schema in the single XML file?
> 
> Michael Kay wrote:
> > 
> > There are not many tools that offer selective validation at the 
> > element level, but you can do it with a schema-aware XQuery 
> or XSLT 2.0 stylesheet:
> > 
> > <xsl:template match="element-to-be-validated">
> >   <xsl:copy-of select="." validation="strict"/> </xsl:template>
> > 
> > Michael Kay
> > http://www.saxonica.com/
> > 
> > 
> 
> hi,
> 
> according to this piece of spec :
> http://www.w3.org/TR/xslt20/#validation
> "The [xsl:]validation attribute is used to request validation 
> against the global element or attribute declaration whose 
> name matches the name of the element or attribute being validated."
> 
> ...if I had a schema like this :
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema version="1.0"
>    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>    <xsd:element name="root" type="rootType" />
>    <xsd:complexType name="rootType">
>      <xsd:sequence>
>        <xsd:element name="product" maxOccurs="unbounded">
>          <xsd:complexType>
>            <xsd:sequence>
>                  <xsd:element name="name" type="xsd:string"/>
>                  <xsd:element name="url">
>                    <xsd:complexType>
>                      <xsd:sequence>
>                          <xsd:element name="product" 
> type="xsd:string"/>
>                          <xsd:element name="image" =
type="xsd:string"/>
>                      </xsd:sequence>
>                    </xsd:complexType>
>                  </xsd:element>
>            </xsd:sequence>
>          </xsd:complexType>
>        </xsd:element>
>      </xsd:sequence>
>    </xsd:complexType>
> </xsd:schema>
> 
> ...that validates this document :
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <root>
>   <product>
>     <name>Product name</name>
>     <url>
>       <product>http://product.url.com</product>
>       <image>http://product.image.com</image>
>     </url>
>   </product>
>   <product>
>     <name>Product name 2</name>
>     <url>
>       <product>http://product.url.com</product>
>       <image>http://product.image.com</image>
>     </url>
>   </product>
> </root>
> 
> ...would it be possible to validate the "product" element ?
> 
> <xsl:template match="product">
>    <xsl:copy-of select="." validation="strict"/> </xsl:template>
> 
> if I understood the story, there is no "global element 
> declaration" for <product>
> 
> more generally, is there a tool (in Java ?) that can validate 
> an arbitrary element against a schema where element 
> declarations are written =E0 la russian-doll ?
> 
> is there a way to achieve this anyway without trying to 
> validate the parent element (and perhaps its ancestors) in 
> order to retrieve the definition ? I think about some 
> conversion to an XPath pattern (or another kind of selector), 
> that would be bound to each definition and that could be 
> tested on the candidate element (all the definitions for a 
> given element would be retrievable in a single set) ?
> 
> mmmh, I wonder if there is not such a flattening mechanism in 
> Relax NG that allows to retrieve the definition(s) of an element
> 
> --
> Cordialement,
> 
>                ///
>               (. .)
>   --------ooO--(_)--Ooo--------
> |      Philippe Poulard       |
>   -----------------------------
>   http://reflex.gforge.inria.fr/
>         Have the RefleX !


From zafar.abbas@m... Wed Jul 26 17:33:28 2006
Received: from wiggum.w3.org ([128.30.52.23])
	by frink.w3.org with esmtp (Exim 4.50)
	id 1G5nGC-0007Hc-I0
	for xmlschema-d


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