Hi John,

I can't help with your other problem, but I think this is straightforward.
When you use an element from some element's substitutionGroup, you
literally get that element.  So any key which is looking to match on the
element you're substituting for can't match, because you've substituted a
different element for the one it needs.

xsi:type gets around this because you're just changing the type of the
element, not using an element with a different name.  So as long as the
things the key is looking for are present in the new type, you won't have
any problems.

So the short answer is you're best off with xsi:type, unless you want to
change your xpath expression to match on any name (use a *).

Hope that helps,
Neil

Neil Graham
XML Parser Development
IBM Toronto Lab
Phone:  905-413-3519, T/L 969-3519
E-mail:  [EMAIL PROTECTED]



"John Powell" <[EMAIL PROTECTED]> on 09/27/2001 04:17:12 PM

Please respond to [EMAIL PROTECTED]

To:   "Xerces-J-User" <[EMAIL PROTECTED]>
cc:
Subject:  Derived types, SubstitutionGroup, Keys and Keyrefs


Dear XercesJ User's List,

I'm trying to use keys and keyrefs to validate the existence of elements
while parsing with the xerces-j v1.4.3 parser. It appears that when I try
to
use substitution groups along with deriving concrete data types from
abstract types that errors are being reported from what appears (to my
inexperienced eyes) to be correct. The errors for the attached files are:

>[Error] animalML.xml:19:9: Key with value [ID Value:  Baby] not found for
> identity constraint of element "Home".
> [Error] animalML.xml:19:9: Key with value [ID Value:  Abby] not found for
> identity constraint of element "Home".
>
The XSV validator does not report errors.
IBM SchemaQuality Checker seems to be trying to tell me something, but I'm
not sure how to interpret the output. Here's a small sampling:
ERROR
 file = file:D:/Projects/0507/research/Schemas/animalML.xsd line 11 column
45
SEVERITY: 0
ERROR TYPE: 2
MESSAGE
No node in element http://www.ara.com/animals:Home corresponds to
<xsd:selector
xpath="AnimalList/Animal"/>
 defined in <xsd:key name="AnimalNameCheck">
    <selector xpath="AnimalList/Animal"/>
    <field xpath="@name"/>
</xsd:key>
. Invalid XPath starting from
http://www.ara.com/animals:Home:AnimalList/Animal.

Finally, when I define the derivations without using substitution groups, I
need to use xsi:type to indicate which concrete derivation in the instance
file. This is a little bit more inconvenient, but the errors go away.

If you got this far, you can probably predict what my questions would be,
but here they are anyway:

Could there be something wrong with my schema or key/keyref definitions,
that xerces doesn't like?
Does anyone have any opinions on the use of substitution groups?

As always, responses are very much appreciated.

John Powell
Applied Research Associates, Inc.


(See attached file: animalML.xml)(See attached file: animalML.xsd)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Attachment: animalML.xml
Description: Binary data

Attachment: animalML.xsd
Description: Binary data

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to