Re: [xsl] Data extraction

Subject: Re: [xsl] Data extraction
From: "Peter Flynn peter@xxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 17 Dec 2018 22:23:18 -0000
On 17/12/2018 17:54, Mailing Lists Mail daktapaal@xxxxxxxxx wrote:
> Hi all
> I have a requirement where I need to write an xslt to extract a
> particular node from source tree.
> 
> 
> Someone wrote an xslt that looked like this.. pseudo code
> 
> Template Match node()|@*
> B  Apply-template select node()|@*
> 
> Template match *:ElementToExtract
> B  B  Copy of select .
> 
> I thought the developer was making a lot of traversing using the above
> approach and he could have instead doneB 
> 
> Template match "/"
> B  B Copy of select descendant::*:ElementToExtract

1. Is the ElementToExtract known to be unique within the document?
Or is your pseudocode masking a more extensive XPath expression to
identify the document?

2. Is this occurring within a pipeline or script? That is, does the
extracted value get passed into some subsequent process as a parameter,
or slotted into some larger data structure for reprocessing? The reason
I ask is that there are simpler tools (eg lxgrep or lxprintf) which can
do a similar task (although the LTxml2 tools are restricted to XPath 1),
eg

lxgrep 'XPath/to/ElementToExtract[predicate]' filename or stdin

Depending on the circumstances, this may be faster if the only
requirement is to extract the identified element in its serialised form.

Peter

Current Thread