all groups > dotnet xml > july 2005 >
You're in the

dotnet xml

group:

XmlValidatingReader 2nd try



XmlValidatingReader 2nd try Bernhard Felkel
7/6/2005 12:14:02 AM
dotnet xml: Hello!

I still have the problem with the XmlValidatingReader in combination with
key/keyref constraints and namespaces.

My schema is quite simple.
I have following key/keyref defined:
<xsd:key name="LangKey">
<xsd:selector xpath="transNS:Language"/>
<xsd:field xpath="@ID"/>
</xsd:key>
<xsd:keyref name="LangKeyRef" refer="transNS:LangKey">
<xsd:selector xpath="transNS:Item/Translation"/>
<xsd:field xpath="@Language"/>
</xsd:keyref>

This describes a translation table. I have a set of languages, each language
has an id (ID-Attribute is the key).
And I have a set of translation items. Each translation item has a link to a
language via the language ID (Langugae attribute -> ID attribute in the
language table). That´s not really complicated, I think.

But the XmlValidatingReader does not recognize if a translation item
references a language which is not defined in language table! And I don´t
know why.

As I mentioned in my last posting, other external XML validators (like
XmlSpy or the Sun XmlValidator) detect the error correctly

And further: If I omit the namespace definition in the schema then the
XmlValidatingReader also works fine! Maybe there´s something wrong with the
namespace definition.

This is really a strange behavior and I don´t know where´s the mistake.

Regards,
RE: XmlValidatingReader 2nd try Bernhard Felkel
7/6/2005 1:29:05 AM
I found the solution!

The prolem was the selector in the keyref
Instead of : '<xsd:selector xpath="transNS:Item/Translation"/>'
you have to write '<xsd:selector xpath="transNS:Item/transNS:Translation"/>

Each element gets the namespace qualifier.

Regards,
Bernhard

[quoted text, click to view]
AddThis Social Bookmark Button