Subject: Re: [xsl] Looking for "real-world" XML documents From: "Dimitre Novatchev dnovatchev@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Sat, 1 Nov 2014 19:50:09 -0000 |
On Sat, Nov 1, 2014 at 11:58 AM, Syd Bauman s.bauman@xxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Looking for "real-world" , Syd Bauman s.bauman@ | Thread | Re: [xsl] Looking for "real-world" , Eliot Kimber ekimber |
Re: [xsl] duplicate elimination, Ihe Onwuka ihe.onwuk | Date | Re: [xsl] Looking for "real-world" , Eliot Kimber ekimber |
Month |