xsl-list
[Top] [All Lists]

Re: [xsl] Looking for "real-world" XML documents

2014-11-01 14:50:24
On Sat, Nov 1, 2014 at 11:58 AM, Syd Bauman s(_dot_)bauman(_at_)neu(_dot_)edu
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:
Things I learned from this & questions:

 * If I had once known you can call document() with a null argument,
   I had forgotten. I've gotten away with using document('/'),
   because I typically call stylesheets like this on themselves. But
   now I see the note at the end of
   http://www.w3.org/TR/xslt20/#document, and that's certainly more
   robust than my method.

 * I love the "tokenize-on-slash, ignore last bit, tack what I want
   on end" technique. Any reason not to use "[ position() lt last() ]"
   as predicate, though?

     No particular reason, but I'd use (pure personal preference):
position() ne last()  . The way this is expressed currently doesn't
affect efficiency, because both arguments are scalars.


 * Does it matter at all what $vDoc is set to? As long as it's
   something that will be matched by the one template in
   "copyDocument" mode, it's OK, right?

Almost agree. Not "something" but a node. This is the only reason a
variable is used here, because inside the <xsl:for-each> instruction
the context item is not a node, and in XSLT ver. 1 and 2 one can only
apply templates on a node-list. In XSLT 3.0 this restriction is
abolished, therefore the stylesheet could be further simplified, by
applying templates on the context item.

One thing worth mentioning is the use of the doc-available() function.
This allows us to try and safely ignore URIs that don't return a
resource and using doc() or document() on them would have resulted in
premature abnormal end. Using doc-available() is particularly handy in
cases like this, when we don't know the exact set of real URIs and
want to explore and obtain whatever is available.


-- 
Cheers,
Dimitre Novatchev
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>