Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [XML Schema 1.1] Using doc() in xs:assert ... the referenced document needs a schema?

From: "C. M. Sperberg-McQueen" <cmsmcq@-------------.--->
To: Andrew Welch <andrew.j.welch@-----.--->
Date: 4/27/2009 4:07:00 AM
On 27 Apr 2009, at 08:48 , Andrew Welch wrote:

>> The current draft of XSD 1.1 says that the set of available  
>> documents is
>> empty, which is another way of saying that you can't usefully use  
>> the doc()
>> function in an assertion.
>
> Ahh that's a shame - I thought it was a great idea.  You could publish
> an xsd, and then have non-technical people maintain the allowed values
> over time.

You can still do that.  Just use SML, which is designed for validation
of sets of documents, with particular emphasis on inter-document  
references,
rather than of single documents in isolation.

If you really need to handle such a scenario with XSD, you could
manage three documents:

   (a) the document with the references (call it doc.xml), managed
       by whoever
   (b) the country file (countries.xml), managed by the non-technical
       people you mention
   (c) a driver file which takes doc.xml and countries.xml and makes
       a single document out of them for purposes of validation:

         <temp-doc xmlns:xi="http://www.w3.org/2001/XInclude">
           <validation-payload>
             <xi:include href=".../doc.xml"/>
           </validation-payload>
           <controlled-vocabularies>
             <xi:include href=".../countries.xml"/>
           </controlled-vocabularies>
         </temp-doc>

Maintain using (a) and (b), validate using (c).

Or alternatively maintain a transform for the countries.xml file which
reads countries.xml and generates a schema document countries.xsd which
contains the enumeration of country names:

   <xsl:template match="/">
     <xsd:schema targetNamespace="mycountrytisofthee">
       <xsd:simpleType name="countrycode">
         <xsd:restriction base="xsd:string">
           <xsl:apply-templates select="//country"/>
         </xsd:restriction>
       </xsd:simpleType>
     </xsd:schema>
   </xsl:template>

   <xsl:template match="country">
     <xsd:enumeration value="{.}"/>
   </xsl:template>

and regenerate countries.xsd whenever countries.xml changes.  Then
Roger's original declaration becomes

   <element name="country" type="tns:countrycode"/>

(This is not QUITE the same as Roger's original:  his code uses
implicit existential quantifiers in the XPath to allow multiple
'country' elements in countries.xml to have the same value.  If
that's important, then the sketches I've given above would need to be
modified; if it's simply an inadvertent error on his part, then
the sketches above may be improvements.)




-- 
****************************************************************
* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
* http://www.blackmesatech.com
* http://cmsmcq.com/mib
* http://balisage.net
****************************************************************





From cmsmcq@b... Mon Apr 27 16:52:16 2009
Received: from maggie.w3.org ([193.51.208.68])
	by frink.w3.org w


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