xsl-list
[Top] [All Lists]

Re: [xsl] Data extraction

2018-12-17 16:23:23
On 17/12/2018 17:54, Mailing Lists Mail daktapaal(_at_)gmail(_dot_)com 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()|@*
  Apply-template select node()|@*

Template match *:ElementToExtract
    Copy of select .

I thought the developer was making a lot of traversing using the above
approach and he could have instead done 

Template match "/"
   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
--~----------------------------------------------------------------
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>