Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Use of data() function

From: "Andrew Welch" <andrew.j.welch@--------->
To:
Date: 3/5/2008 10:50:00 AM
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/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent