Validation of XPaths in xsd? [message #230434] |
Thu, 16 April 2009 09:24 |
Eclipse User |
|
|
|
Originally posted by: wknauf_NO_._INSIDE_hg-online.de
Hi to all,
it seems that when building an xml schema, the XPath expressions of e.g.
"xsd:key" => "xsd:selector" are only validated to be syntactically correct. But
they are not validated to point to valid elements in the current schema.
Assume the following sample:
<xsd:key name="myKey">
<xsd:selector xpath="myschema:element1/myschema:element2" />
<xsd:field xpath="@id" />
</xsd:key>
I think it would be very helpful if the "xsd:selector" path was also validated
and checked for correct elements/attributes. E.g in the above example, WTP could
complain if no element "element1" is found as child of the current element, or
if "element1/element2" has no attribute "id".
The XPath expression is only a subset of the XPath standard
( http://www.w3.org/TR/2001/PR-xmlschema-1-20010330/#coss-iden tity-constraint),
so only element names can occur, and it should be quite simply to validate them.
As there are no errors reported for invalid xpaths when building a XML file for
this schema, it is very annoying for a XSD beginner like me to find out why the
key is not working ;-)
Shall I file an enhancement request, or does my wish make no sense at all ;-).
Thanks
Wolfgang
|
|
|
Re: Validation of XPaths in xsd? [message #230442 is a reply to message #230434] |
Thu, 16 April 2009 11:03 |
Ed Merks Messages: 33139 Registered: July 2009 |
Senior Member |
|
|
Wolfgang,
Comments below.
Wolfgang Knauf wrote:
> Hi to all,
>
> it seems that when building an xml schema, the XPath expressions of
> e.g. "xsd:key" => "xsd:selector" are only validated to be
> syntactically correct. But they are not validated to point to valid
> elements in the current schema.
>
> Assume the following sample:
> <xsd:key name="myKey">
> <xsd:selector xpath="myschema:element1/myschema:element2" />
> <xsd:field xpath="@id" />
> </xsd:key>
That's right, because in the actual instance an element of a derived
type might appear that happens to have a field you'd not know about in
the schema.
>
> I think it would be very helpful if the "xsd:selector" path was also
> validated and checked for correct elements/attributes. E.g in the
> above example, WTP could complain if no element "element1" is found as
> child of the current element, or if "element1/element2" has no
> attribute "id".
Only what's in the XML Schema specification is covered.
>
> The XPath expression is only a subset of the XPath standard
> ( http://www.w3.org/TR/2001/PR-xmlschema-1-20010330/#coss-iden tity-constraint),
> so only element names can occur, and it should be quite simply to
> validate them.
Unfortunately XML is far more complex and the fact that xsi:type and
substitution groups could result in derived types appearing with
additional elements and attributes you'd not anticipate makes that more
challenging.
>
> As there are no errors reported for invalid xpaths when building a XML
> file for this schema, it is very annoying for a XSD beginner like me
> to find out why the key is not working ;-)
At best one could give a warning.
>
> Shall I file an enhancement request, or does my wish make no sense at
> all ;-).
No, I suggest you not because it's not going to happen unless someone
contributes it. :-P
>
> Thanks
>
> Wolfgang
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Validation of XPaths in xsd? [message #230451 is a reply to message #230442] |
Thu, 16 April 2009 13:48 |
Eclipse User |
|
|
|
Originally posted by: dcarver.starstandard.org
As Ed has said, this is a run time option that has to happen when
validating against an XML instance. Syntax is about all that can be
checked and the fact that the XPath parses correctly.
With that said, limited content assistance probably could be done as we
do in the wst.xsl component for XPath assistance and creation.
Dave
Ed Merks wrote:
> Wolfgang,
>
> Comments below.
>
> Wolfgang Knauf wrote:
>> Hi to all,
>>
>> it seems that when building an xml schema, the XPath expressions of
>> e.g. "xsd:key" => "xsd:selector" are only validated to be
>> syntactically correct. But they are not validated to point to valid
>> elements in the current schema.
>>
>> Assume the following sample:
>> <xsd:key name="myKey">
>> <xsd:selector xpath="myschema:element1/myschema:element2" />
>> <xsd:field xpath="@id" />
>> </xsd:key>
> That's right, because in the actual instance an element of a derived
> type might appear that happens to have a field you'd not know about in
> the schema.
>>
>> I think it would be very helpful if the "xsd:selector" path was also
>> validated and checked for correct elements/attributes. E.g in the
>> above example, WTP could complain if no element "element1" is found as
>> child of the current element, or if "element1/element2" has no
>> attribute "id".
> Only what's in the XML Schema specification is covered.
>>
>> The XPath expression is only a subset of the XPath standard
>> ( http://www.w3.org/TR/2001/PR-xmlschema-1-20010330/#coss-iden tity-constraint),
>> so only element names can occur, and it should be quite simply to
>> validate them.
> Unfortunately XML is far more complex and the fact that xsi:type and
> substitution groups could result in derived types appearing with
> additional elements and attributes you'd not anticipate makes that more
> challenging.
>>
>> As there are no errors reported for invalid xpaths when building a XML
>> file for this schema, it is very annoying for a XSD beginner like me
>> to find out why the key is not working ;-)
> At best one could give a warning.
>>
>> Shall I file an enhancement request, or does my wish make no sense at
>> all ;-).
> No, I suggest you not because it's not going to happen unless someone
> contributes it. :-P
>>
>> Thanks
>>
>> Wolfgang
|
|
|
Re: Validation of XPaths in xsd? [message #230464 is a reply to message #230451] |
Thu, 16 April 2009 14:34 |
Eclipse User |
|
|
|
Originally posted by: wknauf_NO_._INSIDE_hg-online.de
So nothing can be done about validation, because the issue is far more complex
than I thought :-(.
Well, thanks for your replies anyway!
Wolfgang
|
|
|
Powered by
FUDForum. Page generated in 0.03665 seconds