Re: declaring xml:id attributes

At 2006-09-14 23:52 +0200, Wolfgang Jeltsch wrote:
>I'm developing a schema in the XML Schema language and want to specify that
>certain elements of my document type have xml:id attributes.  However, the
>name attribute of the xsd:attribute is of type xsd:NCName but xml:id is not a
>NCName.  How do I achieve what I want?

By importing a schema that declares this attribute.

This is what I am doing in my code list validation work:

===========8<------------
Vocabulary schema:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns="urn:oasis:names:tc:ubl:schema:CodeList-Constraints-0.7"
   targetNamespace="urn:oasis:names:tc:ubl:schema:CodeList-Constraints-0.7">

<!-- xml:id per http://www.w3.org/TR/2005/REC-xml-id-20050909/ -->
<xsd:import schemaLocation="xmlid.xsd"
             namespace="http://www.w3.org/XML/1998/namespace"/>

<xsd:annotation>
  <xsd:documentation xml:lang="en">
    A document model of the association of document contexts with the
    URIs of expressions of enumerations of coded values.
...
<!--a given code list with a unique identifier for reference in contexts-->
<xsd:element name="CodeList">
   <xsd:complexType>
     <xsd:attribute ref="xml:id"/>
     <xsd:attribute name="uri" type="xsd:anyURI"/>
   </xsd:complexType>
</xsd:element>


===========8<------------
xmlid.xsd schema:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
   Verbatim from http://www.w3.org/TR/2005/REC-xml-id-20050909/ section D.2

   $Id: xmlid.xsd,v 1.1 2006/06/18 16:56:30 G. Ken Holman Exp $
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://www.w3.org/XML/1998/namespace">

     <xs:attribute name="id" type="xs:ID"/>

</xs:schema>


===========8<------------

I hope this helps.

. . . . . . . . . . Ken

--
UBL/XML/XSLT/XSL-FO training: Vårø, Denmark 2006-10-02/06,11-20/24
UBL International 2006  2006-11-13/17 http://www.ublconference.com
World-wide corporate, govt. & user group UBL, XSL, & XML training.
G. Ken Holman                 mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/x/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05  http://www.CraneSoftwrights.com/x/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Received on Friday, 15 September 2006 02:10:10 UTC