E
Eric Lilja
Sorry for asking so many questions, but I've just started and need to
get some things working so I can do the task that is before me.
Consider this (validating) schema:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="myns" xmlns="myns" elementFormDefault="qualified">
<xs:element name="books">
<xs:complexType>
<xs:sequence>
<xs:element name="book" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="author" minOccurs="1"
maxOccurs="1">
<xs:complexType>
<xs:attribute name="id" type="xs:ID"
use="required"/>
<xs:attribute name="name" type="xs:string"
use="required"/>
</xs:complexType> <!-- authors complexType -->
</xs:element> <!-- author -->
</xs:sequence> <!-- book sequence -->
<xs:attribute name="title" type="xs:string"
use="required"/>
<xs:attribute name="isbn" type="xs:string"
use="required"/>
<xs:attribute name="author-id" type="xs:IDREF"
use="required"/>
</xs:complexType> <!-- book complexType -->
</xs:element> <!-- book -->
</xs:sequence> <!-- books sequence -->
</xs:complexType> <!-- books complexType -->
</xs:element> <!-- books -->
</xs:schema>
I try to use it with the following xml-file:
<?xml version="1.0" encoding="utf-8"?>
<books xmlns="myns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xsi:schemaLocation="myns books-with-id_idref.xsd">
<book title="Winter's Heart" isbn="123456789" author-id="4711">
<author id="4711" name="Robert Jordan"/>
</book>
<book title="Paradiset" isbn="987654321" author-id="1337">
<author id="1337" name="Liza Marklund"/>
</book>
</books>
But I get these errors:
Location: 3:66
Description: cvc-datatype-valid.1.2.1: '4711' is not a valid value for
'NCName'.
Location: 3:59
Description: cvc-attribute.3: The value '4711' of attribute 'author-
id' on element 'book' is not valid with respect to its type, 'IDREF'.
Location: 4:45
Description: cvc-datatype-valid.1.2.1: '4711' is not a valid value for
'NCName'.
Location: 4:16
Description: cvc-attribute.3: The value '4711' of attribute 'id' on
element 'author' is not valid with respect to its type, 'ID'.
Location: 6:61
Description: cvc-datatype-valid.1.2.1: '1337' is not a valid value for
'NCName'.
Location: 6:54
Description: cvc-attribute.3: The value '1337' of attribute 'author-
id' on element 'book' is not valid with respect to its type, 'IDREF'.
Location: 7:45
Description: cvc-datatype-valid.1.2.1: '1337' is not a valid value for
'NCName'.
Location: 7:16
Description: cvc-attribute.3: The value '1337' of attribute 'id' on
element 'author' is not valid with respect to its type, 'ID'.
I've clearly not understood this..what am I doing wrong and what need
I do to get it working?
Thanks for any replies!
- Eric
get some things working so I can do the task that is before me.
Consider this (validating) schema:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="myns" xmlns="myns" elementFormDefault="qualified">
<xs:element name="books">
<xs:complexType>
<xs:sequence>
<xs:element name="book" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="author" minOccurs="1"
maxOccurs="1">
<xs:complexType>
<xs:attribute name="id" type="xs:ID"
use="required"/>
<xs:attribute name="name" type="xs:string"
use="required"/>
</xs:complexType> <!-- authors complexType -->
</xs:element> <!-- author -->
</xs:sequence> <!-- book sequence -->
<xs:attribute name="title" type="xs:string"
use="required"/>
<xs:attribute name="isbn" type="xs:string"
use="required"/>
<xs:attribute name="author-id" type="xs:IDREF"
use="required"/>
</xs:complexType> <!-- book complexType -->
</xs:element> <!-- book -->
</xs:sequence> <!-- books sequence -->
</xs:complexType> <!-- books complexType -->
</xs:element> <!-- books -->
</xs:schema>
I try to use it with the following xml-file:
<?xml version="1.0" encoding="utf-8"?>
<books xmlns="myns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xsi:schemaLocation="myns books-with-id_idref.xsd">
<book title="Winter's Heart" isbn="123456789" author-id="4711">
<author id="4711" name="Robert Jordan"/>
</book>
<book title="Paradiset" isbn="987654321" author-id="1337">
<author id="1337" name="Liza Marklund"/>
</book>
</books>
But I get these errors:
Location: 3:66
Description: cvc-datatype-valid.1.2.1: '4711' is not a valid value for
'NCName'.
Location: 3:59
Description: cvc-attribute.3: The value '4711' of attribute 'author-
id' on element 'book' is not valid with respect to its type, 'IDREF'.
Location: 4:45
Description: cvc-datatype-valid.1.2.1: '4711' is not a valid value for
'NCName'.
Location: 4:16
Description: cvc-attribute.3: The value '4711' of attribute 'id' on
element 'author' is not valid with respect to its type, 'ID'.
Location: 6:61
Description: cvc-datatype-valid.1.2.1: '1337' is not a valid value for
'NCName'.
Location: 6:54
Description: cvc-attribute.3: The value '1337' of attribute 'author-
id' on element 'book' is not valid with respect to its type, 'IDREF'.
Location: 7:45
Description: cvc-datatype-valid.1.2.1: '1337' is not a valid value for
'NCName'.
Location: 7:16
Description: cvc-attribute.3: The value '1337' of attribute 'id' on
element 'author' is not valid with respect to its type, 'ID'.
I've clearly not understood this..what am I doing wrong and what need
I do to get it working?
Thanks for any replies!
- Eric