Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


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

From: Philippe Poulard <Philippe.Poulard@------.-----.-->
To: Michael Kay <mike@--------.--->
Date: 7/26/2006 5:47:00 PM
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 stylesh=
eet:
> 
> <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 noah_mendelsohn@u... Wed Jul 26 13:52:51 2006
Received: from maggie.w3.org ([193.51.208.68])
	by frink.w3.org with esmtp (Exim 4.50)


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