Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Key-keyref to attribute in root element

Reply
Thread Tools

Key-keyref to attribute in root element

 
 
Russell O'Connor
Guest
Posts: n/a
 
      03-05-2004
The following XML and Schema doesn't validate in Visual Studio .NET 2003.
Is there some mistake I'm making, or is VS.NET in error.
The error is

r:\test2.xml(3): The key sequence 'foo' in Keyref fails to refer to some key. An error occurred at , (3, 6).

Any help is appreciated. Here is the schema.

<?xml version="1.0" ?>
<xs:schema id="NewDataSet" targetNamespace="http://tempuri.org/test2.xsd" xmlns:mstns="http://tempuri.org/test2.xsd"
xmlns="http://tempuri.org/test2.xsd" xmlnss="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-comml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="object" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="ref" form="unqualified" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="key" form="unqualified" type="xs:string" />
</xs:complexType>
<xs:key name="rootKey1">
<xs:selector xpath="." />
<xs:field xpath="@key" />
</xs:key>
<xs:keyref name="rootobject" refer="mstns:rootKey1">
<xs:selector xpath=".//mstnsbject" />
<xs:field xpath="@ref" />
</xs:keyref>
</xs:element>
</xs:schema>

And the XML file that fails to validate is:

<?xml version="1.0" encoding="utf-8"?>
<root xmlns="http://tempuri.org/test2.xsd" key="foo">
<object ref="foo" />
</root>

Thanks for any help.

--
Russell
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      03-05-2004


Russell O'Connor wrote:

> The following XML and Schema doesn't validate in Visual Studio .NET 2003.
> Is there some mistake I'm making, or is VS.NET in error.
> The error is
>
> r:\test2.xml(3): The key sequence 'foo' in Keyref fails to refer to some key. An error occurred at , (3, 6).
>
> Any help is appreciated. Here is the schema.
>
> <?xml version="1.0" ?>
> <xs:schema id="NewDataSet" targetNamespace="http://tempuri.org/test2.xsd" xmlns:mstns="http://tempuri.org/test2.xsd"
> xmlns="http://tempuri.org/test2.xsd" xmlnss="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-comml-msdata"
> attributeFormDefault="qualified" elementFormDefault="qualified">
> <xs:element name="root">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="object" minOccurs="0" maxOccurs="unbounded">
> <xs:complexType>
> <xs:attribute name="ref" form="unqualified" type="xs:string" />
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> <xs:attribute name="key" form="unqualified" type="xs:string" />
> </xs:complexType>
> <xs:key name="rootKey1">
> <xs:selector xpath="." />
> <xs:field xpath="@key" />
> </xs:key>
> <xs:keyref name="rootobject" refer="mstns:rootKey1">
> <xs:selector xpath=".//mstnsbject" />
> <xs:field xpath="@ref" />
> </xs:keyref>
> </xs:element>
> </xs:schema>
>
> And the XML file that fails to validate is:
>
> <?xml version="1.0" encoding="utf-8"?>
> <root xmlns="http://tempuri.org/test2.xsd" key="foo">
> <object ref="foo" />
> </root>
>


When I try Xerces J (as provided in jEdit) I don't get any validation
errors.
--

Martin Honnen
http://JavaScript.FAQTs.com/

 
Reply With Quote
 
 
 
 
Henry S. Thompson
Guest
Posts: n/a
 
      03-06-2004
XSV is happy with your example as written, and rejects e.g.

<?xml version="1.0" encoding="utf-8"?>
<root xmlns="http://tempuri.org/test2.xsd" key="foo">
<object ref="foob" />
</root>

--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: http://www.velocityreviews.com/forums/(E-Mail Removed)
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
 
Reply With Quote
 
Russell O'Connor
Guest
Posts: n/a
 
      04-10-2004
The following seems legal to me, but I can't get MSXML or XMLSPY to
validate this properly. Is it valid for me to have a keyref attribute
refer to a fixed (but hidden) name?

Here is the schema:

<?xml version="1.0" ?>
<xs:schema id="NewDataSet" targetNamespace="http://tempuri.org/test2.xsd"
xmlns:mstns="http://tempuri.org/test2.xsd"
xmlns="http://tempuri.org/test2.xsd"
xmlnss="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-comml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="object" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="ref" form="unqualified" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="key" form="unqualified" type="xs:string" fixed="foo" />
</xs:complexType>
<xs:key name="rootKey1">
<xs:selector xpath="." />
<xs:field xpath="@key" />
</xs:key>
<xs:keyref name="rootobject" refer="mstns:rootKey1">
<xs:selector xpath=".//mstnsbject" />
<xs:field xpath="@ref" />
</xs:keyref>
</xs:element>
</xs:schema>

and here is the XML.

<?xml version="1.0" encoding="utf-8"?>
<root xmlns="http://tempuri.org/test2.xsd">
<object ref="foo" />
</root>

 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      04-11-2004


Russell O'Connor wrote:

> The following seems legal to me, but I can't get MSXML or XMLSPY to
> validate this properly. Is it valid for me to have a keyref attribute
> refer to a fixed (but hidden) name?
>
> Here is the schema:
>
> <?xml version="1.0" ?>
> <xs:schema id="NewDataSet" targetNamespace="http://tempuri.org/test2.xsd"
> xmlns:mstns="http://tempuri.org/test2.xsd"
> xmlns="http://tempuri.org/test2.xsd"
> xmlnss="http://www.w3.org/2001/XMLSchema"
> xmlns:msdata="urn:schemas-microsoft-comml-msdata"
> attributeFormDefault="qualified" elementFormDefault="qualified">
> <xs:element name="root">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="object" minOccurs="0" maxOccurs="unbounded">
> <xs:complexType>
> <xs:attribute name="ref" form="unqualified" type="xs:string" />
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> <xs:attribute name="key" form="unqualified" type="xs:string" fixed="foo" />
> </xs:complexType>
> <xs:key name="rootKey1">
> <xs:selector xpath="." />
> <xs:field xpath="@key" />
> </xs:key>
> <xs:keyref name="rootobject" refer="mstns:rootKey1">
> <xs:selector xpath=".//mstnsbject" />
> <xs:field xpath="@ref" />
> </xs:keyref>
> </xs:element>
> </xs:schema>
>
> and here is the XML.
>
> <?xml version="1.0" encoding="utf-8"?>
> <root xmlns="http://tempuri.org/test2.xsd">
> <object ref="foo" />
> </root>


I don't get any errors with Xerces J.
With MSXML 4 and 5 I get an error for the missing key, not for the keyref.
And the .NET validator complaints about a keyref not referencing a key:
http://apps.gotdotnet.com/xmltools/x...r/Default.aspx

--

Martin Honnen
http://JavaScript.FAQTs.com/

 
Reply With Quote
 
Henry S. Thompson
Guest
Posts: n/a
 
      04-27-2004
XSV is happy with your example docs, and unhappy if I change the
'fixed' attr to a different value.

The REC explicitly notes that e.g. keys can be satisfied by default or
fixed values supplied by value constraints.

ht
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: (E-Mail Removed)
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"How To Get Attribute Value Of Root Element"? pbd22 Javascript 1 07-03-2007 02:27 PM
Validation (XHTML 1.0 Transitional): Attribute 'height' is not a valid attribute of element 'table' perspolis ASP .Net 1 01-23-2007 07:57 AM
Attribute 'ms_2d_layout' is not a valid attribute of element 'tabl =?Utf-8?B?TWFyaw==?= ASP .Net 4 12-14-2006 06:39 AM
Can be multiple instances of element used as the root element? VK XML 8 10-31-2006 06:51 PM
Validation (XHTML 1.0 Transitional): Attribute 'leftmargin' is not a valid attribute of element 'body'. anonymous ASP .Net 1 08-02-2006 08:05 AM



Advertisments