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

Re: Use of data() function

Subject: Re: Use of data() function
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Wed, 5 Mar 2008 10:49:17 +0000
Re:  Use of data() function
On 05/03/2008, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> >
>  > ...which is a bit odd to me at the moment.  It seems a bit of
>  > an artificial restriction.
>  >
>
> The basis for the distinction is the theory that with mixed content, it
>  makes sense to treat the markup as mere decoration of the text, whereas with
>  element-only content, concatenating the children is a meaningless operation.
>  In both cases I think the assumption is probably correct 95% of the time,
>  and in the 5% of cases where it's wrong, the rule doesn't do much harm.

That's a nice way of putting it.

It is slightly funny though, that given:

<data>
  <somedata>important data</somedata>
  <somedata>even more important data</somedata>
</data>

calling data() on that results in an error, and that's at the request
of the data heads.

Intuitively (for me at least) I would expect it to concatenate the
data items with a space separator.  Where the content was mixed, you
wouldn't need the separator.

Perhaps the data() function should be avoided - just use the
appropriate constructor instead.  For example, the data(@married)
example[1] - as long as @married is typed then test="data(@married)"
will work as expected.  If it's untyped and @married="false" then
data(@married) returns true, so the result will change depending on
whether the source has been validated or not.

If however you do test="xs:boolean(@married)" then it works as
expected regardless of validatation.

[1] http://schema-aware.com/xslt/data-function.html


-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

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.