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

RE: 3 XSLT2 quickies

Subject: RE: 3 XSLT2 quickies
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 17 Mar 2006 09:53:14 -0000
child schema
> Can anyone help me sort of (I don't have a running Saxon around):
> 
> 1) If the element a is declared with, say, the simple 
> nonatomic IDREFS 
> type as its simpleContent
> 
> and I have an instance document with
> 
> <a> foo bar baz</a>
> 
> and that a element becomes the context node for
>   <value-of select="."/>
> 
> I should get as output the (one) text node with
> foo bar baz
> 
> right? But really, behind the scenes, it was atomized and 
> re-de-atomized 
> :), so I assume that
>   <value-of select="." separator="-ostrich-"/>
> 
> should get me
> foo-ostrich-bar-ostrich-baz

Correct. The detailed rules are in 5.7.2:

#Zero-length text nodes in the sequence are discarded.

#Adjacent text nodes in the sequence are merged into a single text node.

#The sequence is atomized.

#Every value in the atomized sequence is cast to a string.

#The strings within the resulting sequence are concatenated, with a
(possibly zero-length) separator inserted between successive strings. 

> 
> If not, well what about:
>   <value-of select="./text()" />
> or
>   <value-of select="./text()" separator="-ostrich-"/>
> 
> My _understanding_ is that they should both just output
> 
> foo bar baz
> 
> because text() doesn't atomize, but I am open for any objections.

Actually the text nodes *are* atomized, but the result of atomizing a text
node is a single string, regardless of the type annotation of the parent
element.

Note also that the rule about concatenating text nodes comes into play here:
if your input were

<a>foo<!--hey!-->bar</a>

the result would be "foobar" rather than "foo-ostrich-bar" because of the
rule that adjacent text nodes are concatenated before atomization.

> 
> document-node(schema-element(rubberduck))
> 
> node test is one bastard to analyze (I'm doing static 
> analysis on XSLT): 
> It tests not one, but tow nodes.
> 
> Are there any great dangers in converting it to
> 
> document-node()[child::schema-element(rubberduck)]
> 

Obviously this only works when used as a step in a path expression, or as a
pattern: not for example when used in an "as" attribute.

Technically I think the rewrite is more like:

document-node()[count(child::*)=1 and count(child::text()=0) and
(child::schema-element(rubberduck))]

Michael Kay
http://www.saxonica.com/

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.