[dsdl-comment] Re: Problem with specifying the <Book> section occur only within the <soap:Body> element

From: George Cristian Bina <george@oxygenxml.com>
Date: Tue May 20 2008 - 08:15:07 UTC

Hi Roger,

The NVDL script will create two validation candidates from the sample
document, one containing the whole document and that will be validated
against the soap.xsd schema and one containing the elements from the
http://www.books.com namespace and that will be validated against the
Book.rng schema.

The error reported by oNVDL is related to the first validation, when the
whole document is validated against the soap.xsd schema. As it is
defined the Body element can contain any element from other namespaces
but the default value for xs:any/@processContents is strict which means
that those elements need to be valid. If you specify a value of lax or
strict fot the processContents attribute then the whole document will be
validated by the soap.xsd schema:

     <xsd:element name="Body">
         <xsd:complexType>
             <xsd:choice>
                 <xsd:any processContents="lax"
                          namespace="##other" maxOccurs="unbounded"/>
                 <xsd:element ref="Fault"/>
             </xsd:choice>
         </xsd:complexType>
     </xsd:element>

Best Regards,
George

--
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Costello, Roger L. wrote:
> Hi Folks,
> 
> I want to restrict the <Book> section to occur only within the
> <soap:Body> element, as shown here:
> 
> ------------------------------------------
> SOAP-Book.xml
> ------------------------------------------
> <?xml version="1.0"?>
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
>       <soap:Body>
>           <Book xmlns="http://www.books.com">
>              <Title>The Wisdom of Crowds</Title>
>              <Author>James Surowiecki</Author>
>              <Date>2005</Date>
>              <ISBN>0-385-72170-6</ISBN>
>              <Publisher>Anchor Books</Publisher>
>          </Book>
>       </soap:Body>
> </soap:Envelope>
> 
> Here is my NVDL script:
> 
> ------------------------------------------
> SOAP-Book.nvdl
> ------------------------------------------
> <?xml version="1.0"?>
> <rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0"
>        startMode="soap">
>      <mode name="soap">
>          <namespace ns="http://schemas.xmlsoap.org/soap/envelope/">
>              <validate schema="soap.xsd">
>                  <context path="Body" useMode="book" />
>              </validate>
>          </namespace>
>      </mode>
>      <mode name="book">
>          <namespace ns="http://www.books.com">
>              <validate schema="Book.rng" />
>              <attach />
>          </namespace>
>      </mode>
> </rules>
> 
> When I run it using oNVDL I get an error message saying that I have an
> error in my instance document, at the <Book> element. What am I doing
> wrong?  Below is Book.rng and soap.xsd.  /Roger
> 
> ------------------------------------------
> Book.rng
> ------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <element name="Book" xmlns="http://relaxng.org/ns/structure/1.0"
>          ns="http://www.books.com">
>       <element name="Title">
>           <text/>
>       </element>
>       <element name="Author">
>           <text/>
>       </element>
>       <element name="Date">
>           <text/>
>       </element>
>       <element name="ISBN">
>           <text/>
>       </element>
>       <element name="Publisher">
>           <text/>
>       </element>
> </element>
> 
> ------------------------------------------
> soap.xsd
> ------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>             targetNamespace="http://schemas.xmlsoap.org/soap/envelope/"
>             xmlns="http://schemas.xmlsoap.org/soap/envelope/"
>             elementFormDefault="unqualified">
>     <xsd:element name="Envelope">
>         <xsd:complexType>
>             <xsd:sequence>
>                 <xsd:element ref="Header" minOccurs="0"/>
>                 <xsd:element ref="Body"/>
>             </xsd:sequence>
>         </xsd:complexType>
>     </xsd:element>
>     <xsd:element name="Header">
>         <xsd:complexType>
>             <xsd:sequence>
>                 <xsd:any namespace="##other" maxOccurs="unbounded"/>
>             </xsd:sequence>
>         </xsd:complexType>
>     </xsd:element>
>     <xsd:attribute name="mustUnderstand" type="xsd:boolean"
> default="false"/>
>     <xsd:element name="Body">
>         <xsd:complexType>
>             <xsd:choice>
>                 <xsd:any namespace="##other" maxOccurs="unbounded"/>
>                 <xsd:element ref="Fault"/>
>             </xsd:choice>
>         </xsd:complexType>
>     </xsd:element>
>     <xsd:element name="Fault">
>         <xsd:complexType>
>             <xsd:sequence>
>                 <xsd:element name="faultcode" type="xsd:QName"/>
>                 <xsd:element name="faultstring" type="xsd:string"/>
>             <xsd:element name="faultactor" type="xsd:anyURI"/>
>                 <xsd:element name="detail" minOccurs="0">
>                     <xsd:complexType>
>                         <xsd:sequence>
>                             <xsd:any namespace="##other"
> maxOccurs="unbounded"/>
>                         </xsd:sequence>
>                     </xsd:complexType>
>                 </xsd:element>
>             </xsd:sequence>
>         </xsd:complexType>
>     </xsd:element>
> </xsd:schema>
> --
> DSDL comments
> 
> To unsubscribe, please send a message with the
> command  "unsubscribe" to dsdl-comment-request@dsdl.org
> (mailto:dsdl-comment-request@dsdl.org?Subject=subscribe)
> 
--
DSDL comments
To unsubscribe, please send a message with the
command  "unsubscribe" to dsdl-comment-request@dsdl.org
(mailto:dsdl-comment-request@dsdl.org?Subject=unsubscribe)
Received on Tue May 20 10:15:10 2008

This archive was generated by hypermail 2.1.8 : Tue May 20 2008 - 15:38:02 UTC