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

Re: Why does this XPath expression work fine when run

Subject: Re: Why does this XPath expression work fine when run in Oxygen but fails when used in an XSD 1.1 assert element?
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 2 Dec 2019 18:12:51 -0000
Re:  Why does this XPath expression work fine when run
Furthermore, if you put the assertion on a parent element, then by default the
XDM instance against which the assertion is run has all comment and PI nodes
stripped (on the theory that comments and PIs should not affect the validity
of a document).

<quote>
XSD 1.1 part 1 B'3.13.4.1 clause 1.2: By default, comments and processing
instructions are excluded from the partial B7post-schema-validation infosetB7,
but B7at user optionB7 processors may retain comments and processing
instructions instead of excluding them.

Note: If comments and processing instructions are retained, the consequence
will be that assertions are able to test for their presence or absence and to
examine their contents.
</quote>

Saxon provides an option to retain comments and PIs for evaluating assertions

Michael Kay
Saxonica

> On 2 Dec 2019, at 17:50, G. Ken Holman g.ken.holman@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> The data model within which an assertion is evaluated is comprised only of
the element itself, not its siblings. You are looking at siblings.
>
> Per the specification:
>
> https://www.w3.org/TR/xmlschema11-1/#sec-cvc-assertion
>
> I hope this helps.
>
> . . . . . . Ken
>
> At 2019-12-02 17:27 +0000, Costello, Roger L. costello@xxxxxxxxx wrote:
>> Hi Folks,
>>
>> Below is a sample XHTML document. Immediately following the <style> element
is a comment. I want to ensure that the value in the comment starts with this
string:
>>
>>        [if gte mso 9]><xml>
>>
>> Using Oxygen, I ran the following XPath query (the <head> element is the
context node):
>>
>> *[local-name() eq 'style']/following-sibling::comment()[1]/starts-with(.,
'[if gte mso 9]>&lt;xml>')
>>
>> The result of running the query is:
>>
>>        true()
>>
>> Perfect!
>>
>> Next, I put the query into an XML Schema 1.1 assert element:
>>
>> <xs:assert test="*[local-name(.) eq
'style']/following-sibling::comment()[1]/starts-with(., '[if gte mso
9]>&lt;xml>')" />
>>
>> When I validated the XHTML document against the XML Schema, I got this
error:
>>
>> Assertion evaluation ('*[local-name(.) eq
'style']/following-sibling::comment()[1]/starts-with(., '[if gte mso
9]><xml>')') for element 'head' on schema type 'headType' did not succeed.
>>
>> Why does the XPath query work fine when run in Oxygen but fails when used
in an XSD 1.1 assert element?  /Roger
>>
>> Here's the XHTML document:
>
>
> --
> Contact info, blog, articles, etc. http://www.CraneSoftwrights.com/s/ |
> Check our site for free XML, XSLT, XSL-FO and UBL developer resources |
> Streaming hands-on XSLT/XPath 2 training class @ US$45 (5 hours free) |
> Essays (UBL, XML, etc.) http://www.linkedin.com/today/author/gkholman |

Current Thread

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
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.