[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: key and keyref issues

  • From: John Dziurlaj <john@hiltonroscoe.com>
  • To: Ghislain Fourny <gfourny@inf.ethz.ch>, Michael Kay <mike@s...>
  • Date: Wed, 30 May 2018 11:58:26 -0400

RE:  key and keyref issues
I added an explicit namespace (n1) and updated the constraints to use it:

New xsd:schema tag:

<xsd:schema xmlns="NIST_V2_election_results_reporting.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:n1="NIST_V2_election_results_reporting.xsd"
targetNamespace="NIST_V2_election_results_reporting.xsd"
elementFormDefault="qualified" version="2.0">

New constraints:

<xsd:key name="personKey">
	<xsd:selector xpath="./n1:Person"/>
	<xsd:field xpath="@ObjectId"/>
</xsd:key>
<xsd:keyref name="personKeyRef" refer="personKey">
	<xsd:selector xpath="./n1:Election/n1:Candidate"/>
	<xsd:field xpath="n1:PersonId"/>
</xsd:keyref>

And now the validation works as expected. I must say I'm not sure why I need
the namespace, when I'm not using it anywhere else in the XSD.

Thanks,

John.

-----Original Message-----
From: Ghislain Fourny <gfourny@inf.ethz.ch>
Sent: Wednesday, May 30, 2018 11:52 AM
To: Michael Kay <mike@saxonica.com>
Cc: John Dziurlaj <john@hiltonroscoe.com>; xml-dev@l...; Sam Dana
<s.dana@prometheuscomputing.com>
Subject: Re:  key and keyref issues

Dear John,

I agree with Mike -- however I also do see that in your document you are
referring to types using no prefixes either, which may indicate that you are
declaring a default namespace.

Maybe if you would share your entire document, it would help narrow down the
issue, or at least all the attributes and xmlns/targetNamespace bindings,
usually all at the xsd:schema element.

Thanks and kind regards,
Ghislain


> On 30 May 2018, at 17:41, Michael Kay <mike@saxonica.com> wrote:
>
> The elements in the source document are all in a namespace but the path
> expressions in your key definitions are looking for elements in no
> namespace.
>
> Michael Kay
> Saxonica
>
>> On 30 May 2018, at 16:33, John Dziurlaj <john@hiltonroscoe.com> wrote:
>>
>> I’m attempting to constrain a schema, which has a lot of xsd:ID and
>> xsd:IDREF, so that, for example, a Person IDREF can only refer to a
>> Person ID.
>>
>> I wrote a key and keyref constraint thus:
>>
>> <xsd:element name="ElectionReport" type="ElectionReport">
>>       <xsd:key name="personKey">
>>            <xsd:selector xpath="./Person"/>
>>            <xsd:field xpath="@ObjectId"/>
>>       </xsd:key>
>>       <xsd:keyref name="personKeyRef" refer="personKey">
>>            <xsd:selector xpath="./Election/Candidate"/>
>>            <xsd:field xpath="PersonId"/>
>>       </xsd:keyref>
>> </xsd:element>
>>
>> However, when I try it against an example I wrote up (which should throw
>> a validation error), it succeeds with no errors.
>>
>> I’ve attached both my schema and example file. I am using XMLSpy to
>> validate my instances.
>>
>> Thanks,
>>
>> John Dziurlaj
>>
>> Elections Consultant
>> Hilton Roscoe LLC
>> Cell 330-714-8935 Work/Fax 234-706-6434
>>
>> <idc_test.xml><NIST_V2_election_results_reporting.xsd>_______________
>> ________________________________________________________
>>
>> XML-DEV is a publicly archived, unmoderated list hosted by OASIS to
>> support XML implementation and development. To minimize spam in the
>> archives, you must subscribe before posting.
>>
>> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
>> Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
>> subscribe: xml-dev-subscribe@lists.xml.org List archive:
>> http://lists.xml.org/archives/xml-dev/
>> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
>


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.