Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   Key-keyref to attribute in root element (http://www.velocityreviews.com/forums/t166793-key-keyref-to-attribute-in-root-element.html)

Russell O'Connor 03-05-2004 03:05 PM

Key-keyref to attribute in root element
 
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" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-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=".//mstns:object" />
<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

Martin Honnen 03-05-2004 03:55 PM

Re: Key-keyref to attribute in root element
 


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" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-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=".//mstns:object" />
> <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/


Henry S. Thompson 03-06-2004 09:40 AM

Re: Key-keyref to attribute in root element
 
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: ht@inf.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]

Russell O'Connor 04-10-2004 11:53 PM

Key-keyref to fixed attribute (Was: Key-keyref to attribute in root element)
 
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"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-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=".//mstns:object" />
<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>


Martin Honnen 04-11-2004 11:22 AM

Re: Key-keyref to fixed attribute (Was: Key-keyref to attribute inroot element)
 


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"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:msdata="urn:schemas-microsoft-com:xml-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=".//mstns:object" />
> <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/


Henry S. Thompson 04-27-2004 08:32 AM

Re: Key-keyref to fixed attribute
 
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: ht@inf.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]


All times are GMT. The time now is 06:47 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.