473,216 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,216 software developers and data experts.

Schema with ID/IDREF validates, but xml-file that uses it does not

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

Feb 21 '07 #1
3 9877
On Feb 21, 8:22 pm, "Eric Lilja" <mindcoo...@gmail.com>
wrote:
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.
Read a book. You're not going to learn much if you just ask
lots of questions and make no effort to learn on your own.

http://www.w3.org/TR/xmlschema-0/

....is a good enough starting point for learning about XML
Schemata.
Location: 3:66
Description: cvc-datatype-valid.1.2.1: '4711' is not a
valid value for 'NCName'.
It tells you precisely what is wrong with your document.
You declared this attribute as xs:IDREF. '4711' is not a
valid xs:IDREF value. Finding out why should be trivial
for anyone with intelligence quotient higher than their
shoe size.

XML Schema Recommendations are published by W3C. On their
website you should see an XML Schema section in the list of
available topics. Click there.

You need Specifications and Development sub-sections. Click
on it.

'XML Schema Part 2: Datatypes' looks like it might help
you. Click it.

Search for IDREF. Click on the link. The text says that
IDREF is the set of all string that match the NCName
production. Click on NCName.

[4] NCName ::= (Letter | '_') (NCNameChar)*

Here it goes... looks like IDREF's (and ID's) have to start
with a letter or an underscore. That's your immediate
problem, and the error message you received together with
good ole rubbing a couple of brain cells together should've
gotten you there in two minutes or so.
I've clearly not understood this..what am I doing wrong
and what need I do to get it working?
I think it would be harmful for you to simply tell you how
it's done. But I'll give you an awfully good hint: XML
Schema Part 0: Primer document I referred above contains
the information necessary for doing it right.

--
roy axenov

Feb 21 '07 #2
On 21 Feb, 19:46, "roy axenov" <r_axe...@mail.ruwrote:
On Feb 21, 8:22 pm, "Eric Lilja" <mindcoo...@gmail.com>
wrote:
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.

Read a book. You're not going to learn much if you just ask
lots of questions and make no effort to learn on your own.
I have the book Internet and the World Wide Web How to program, which,
briefly, discusses xml. I'm starting out with several "technologies"
related to web right now so that book seemed a good purchase. Since
the book is a bit light on XML I've been using the web alongside. XML
is one thing that I want to have more than a cursory knowledge of,
though, so I'm trying to decide on a good book. I was looking at
O'Reilly's selection and plan to visit the local campus library to do
some browsing and see which one I like. One of my upcoming projects is
changing my applications to use xml for storing user settings and
whatnot.
>
http://www.w3.org/TR/xmlschema-0/

...is a good enough starting point for learning about XML
Schemata.
This link keeps turning up when I google but, unfortunately, the
information is somewhat densely presented for me at the moment.
>
Location: 3:66
Description: cvc-datatype-valid.1.2.1: '4711' is not a
valid value for 'NCName'.

It tells you precisely what is wrong with your document.
You declared this attribute as xs:IDREF. '4711' is not a
valid xs:IDREF value. Finding out why should be trivial
for anyone with intelligence quotient higher than their
shoe size.

XML Schema Recommendations are published by W3C. On their
website you should see an XML Schema section in the list of
available topics. Click there.

You need Specifications and Development sub-sections. Click
on it.

'XML Schema Part 2: Datatypes' looks like it might help
you. Click it.

Search for IDREF. Click on the link. The text says that
IDREF is the set of all string that match the NCName
production. Click on NCName.

[4] NCName ::= (Letter | '_') (NCNameChar)*

Here it goes... looks like IDREF's (and ID's) have to start
with a letter or an underscore. That's your immediate
problem, and the error message you received together with
good ole rubbing a couple of brain cells together should've
gotten you there in two minutes or so.
I've clearly not understood this..what am I doing wrong
and what need I do to get it working?

I think it would be harmful for you to simply tell you how
it's done. But I'll give you an awfully good hint: XML
Schema Part 0: Primer document I referred above contains
the information necessary for doing it right.
A bit rudely put I think, but I guess that's easy on the internet. I
did search for it, though, but I didn't look closely enough and was
confused by an example that used integer literals as IDs. But, you're
right, I should have been able to find the proper definition myself.
Anyway, you solved my problem and for that I say thanks.
>
--
roy axenov
- Eric

Feb 21 '07 #3
Reading W3C documents, even introductory ones, does assume a basic level
of experience which beginners may not have. They're written by experts,
for experts, so they tend to be terse; the official goal seems to be to
make them "prescriptive, not descriptive", and I actually got some
pushback when folks felt I was crossing that line. The assumption seems
to be that other people will take the W3C books and write tutorial
material based on them.

And, in fact, there are also many tutorials and introductory articles
available on the web.

I hope folks will forgive me for blowing the company trumpet again and
reminding everyone that many of those resources can be found at
http://www.ibm.com/xml
And in other places, of course.
Feb 21 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jari Kujansuu | last post by:
I can successfully parse XML document using SAX or DOM and I can also validate XML document against schema. Problem is that my program should deal with user-defined schemas which means that when...
2
by: Miel Bronneberg | last post by:
Hi, I've got a problem validating an xml document with both a dtd and a schema. The problem seems to be about namespaces. What I want is a well-formed, valid XML document, which also validates...
8
by: Jakob Møbjerg Nielsen | last post by:
Hi Is it possible to represent a linked list in XML-Schema. Somthing like: <xsd:complexType name="Llist" > <xsd:sequence> <xsd:element name="content" type="xsd:string"/> <xsd:element...
0
by: chobin | last post by:
Hi all. I've a terrible question. I've to build one XML page (based on a xml schema) that implements a dynamic database. In particular, I would declare something like this: <?xml version="1.0"...
0
by: peterpeter | last post by:
Hi. There is a XML schema problem that I have with key/keyref: I have two complex (A and B) types which both inherit from a common base typ (Base). A refers B using a xs:IDREF element named...
4
by: Iain A. Mcleod | last post by:
Hi I'm stuck with the following schema validation problem in VS.NET 2003: I have two types of xml document and related schema: project and projectCollection. A projectcollection is just a set...
3
by: farseer | last post by:
Hello, i have a schema which also imports the XHTML schema: <xsd:import namespace="http://www.w3.org/1999/xhtml" schemaLocation="http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd"/> This...
5
by: Lemon Tree | last post by:
Hello everybody. I have a problem with Schema Definitions and I cannot figure out how to solve it (provided that it could be solved :)) Here we go... Let's suppose to have a simple XML file...
1
by: stran | last post by:
I'm trying to create a simple type that holds two different types. The first is IDREF and the second is an enumeration of string. When I generate a sample xml, I can enter any ID previously stated in...
3
by: Kai Schlamp | last post by:
Hello! In my schema I have the following: <xs:complexType name="textareaType"> <xs:simpleContent> <xs:restriction base="xs:string"> <xs:attribute ref="label" use="required" />...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.