[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] XPath expression that generates false plus a message?


Subject: RE: [xsl] XPath expression that generates false plus a message?
From: "Costello, Roger L." <costello@xxxxxxxxx>
Date: Mon, 25 Apr 2011 06:00:13 -0400

Hi David,

> You said it didn't work, but you didn't say what you did or what effect
> you saw.

I used the XPath expression within the new XML Schema 1.1 <assert> element:

    <xs:element name="meeting">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="start" type="xs:time" />
                <xs:element name="end" type="xs:time" />
            </xs:sequence>
            <xs:assert test="if (xs:time(start) gt xs:time(end)) then
                                                     true()
                                               else
                                                      trace(false(), 'Hey, the
meeting ends before it begins!')" />
        </xs:complexType>
    </xs:element>

Here is a <meeting> with bad data:

<meeting>
     <start>10:00:00</start>
     <end>09:00:00</end>
</meeting>

I want an error to be thrown on this bad data. That will happen only if the
"else" part returns a false. Since no error was thrown, I infer that the
trace() function did not return false().

What are your thoughts on this?

/Roger

-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx]
Sent: Monday, April 25, 2011 5:46 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Cc: Costello, Roger L.
Subject: Re: [xsl] XPath expression that generates false plus a message?

On 25/04/2011 10:38, Costello, Roger L. wrote:
> If there any way to return a false, but have a string come along with it?

The code you posted.

You said it didn't work, but you didn't say what you did or what effect
you saw.

David


Current Thread
Keywords