Hi Eddie,
I made the changes that you suggested, and it worked like a charm!
Great!
Thanks so much.
Now I have another question. DOMParser merrily validates an xml
instance doc that contains an empty key value (e.g., <Name></Name
or <Name/>, while such doc crashes xsv. The node value of the <Name>
node in the DOM tree actually is null, as expected. It looks like that
xerces2-j DOMParser treats such value as an empty string, i.e., "".
I was expecting that an empty key value would prompt a key violation.
After all, what is the use of a key if it is empty? But that is not the case.
So, except to enforce a key of string type to be non-empty by restricting
its minLength, is there a way that uses some aspects of XML Schema's
key constraint?
I'm not sure about this and I couldn't find anything in the XML Schema spec about this. You can send an email to the W3C XML Schema mailing list [1] for questions like these.
Cheers, /Eddie
[1] [EMAIL PROTECTED]
-Shengyou
At 10:03 AM 06/21/2002 +1000, Eddie Robertsson wrote:
Hi,
Thanks, Eddie. I did what you suggested too, and retested again after reading your message. The parser still doesn't complain.
I had a closer look and I didn't realize that you used a targetNamespace for your schema. Since the selector and field elements use XPath notation you will have to declare a prefix for your namespace that you can use in the XPath expression. The reason for this is that XPath doesn't support default namespaces. See below.
You have to add a namespace declaration with a prefix for your targetNamespace as well. For example:<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.bts.com/pcsp"
xmlns="http://www.bts.com/pcsp" xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
xmlns:p="http://www.bts.com/pcsp"
In the xpath attribute for selector and field you must use this new declared prefix on your elements:
<xs:element name="Contact"> <xs:complexType> <xs:sequence> <xs:element name="Name" type="xs:string"/> <xs:element name="Title" type="xs:string"/> <xs:element name="Phone" type="xs:string"/> <xs:element name="Email" type="xs:string"/> </xs:sequence> </xs:complexType> <xs:key name="ContactKey"> <xs:selector xpath="Contact"/> <xs:field xpath="Name"/> </xs:key>
<xs:key name="ContactKey"> <xs:selector xpath="p:Contact"/> <xs:field xpath="p:Name"/> </xs:key>
Cheers, /Eddie
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
