Mercurial > repos > iuc > xpath
annotate xpath.xml @ 7:a890cac292f3 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/xpath commit 8cbc5a00fac3f19591b1f956610f0cc60810dab2
| author | iuc |
|---|---|
| date | Tue, 28 Nov 2017 05:13:13 -0500 |
| parents | 3619c6fb132d |
| children |
| rev | line source |
|---|---|
| 0 | 1 <?xml version="1.0"?> |
| 2 <tool id="xpath" name="XPath" version="@WRAPPER_VERSION@.0"> | |
| 3 <description>compute xpath expressions on XML data</description> | |
| 4 <macros> | |
| 5 <import>macros.xml</import> | |
| 6 </macros> | |
| 7 <expand macro="requirements"/> | |
| 8 <expand macro="stdio"/> | |
|
6
3619c6fb132d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/xpath commit c9d0e222bf9ec49f5a58a2d7f9990310933d71e9
iuc
parents:
5
diff
changeset
|
9 <command><![CDATA[perl $__tool_directory__/xpath -q -e '$expression' $input > $output]]></command> |
| 0 | 10 <inputs> |
| 11 <param name="input" type="data" format="xml" label="Input XML data"/> | |
| 12 <param name="expression" type="text" label="XPath Query"> | |
| 13 <sanitizer> | |
| 14 <valid> | |
| 15 <add value="""/> | |
| 16 <add value="["/> | |
| 17 <add value="]"/> | |
| 18 <add value="@"/> | |
| 19 </valid> | |
| 20 </sanitizer> | |
| 21 </param> | |
| 22 </inputs> | |
| 23 <outputs> | |
| 24 <!-- TODO: sometimes there's text output (e.g. text() queries) --> | |
| 25 <data format="xml" name="output" label="XPath expression on $input.name"/> | |
| 26 </outputs> | |
| 27 <tests> | |
| 28 <test> | |
| 29 <param name="input" value="test.xml"/> | |
| 30 <param name="expression" value="//b[@attr="value"]" /> | |
| 31 <output name="output" file="1.xml"/> | |
| 32 </test> | |
| 33 <test> | |
| 34 <param name="input" value="test.xml"/> | |
| 35 <param name="expression" value="//b[@attr]" /> | |
| 36 <output name="output" file="2.xml"/> | |
| 37 </test> | |
| 38 <test> | |
| 39 <param name="input" value="test.xml"/> | |
| 40 <param name="expression" value="//b/text()" /> | |
| 41 <output name="output" file="3.xml"/> | |
| 42 </test> | |
| 43 </tests> | |
| 44 <help><![CDATA[ | |
| 45 **What it does** | |
| 46 | |
| 47 Query XML files with XPath expressions. | |
| 48 | |
| 49 For an example input file:: | |
| 50 | |
| 51 <root> | |
| 52 <IdList> | |
| 53 <Id>1234</Id> | |
| 54 <Id>1235</Id> | |
| 55 <Id>1236</Id> | |
| 56 <Id>1237</Id> | |
| 57 </IdList> | |
| 58 </root> | |
| 59 | |
| 60 One could query out the IDs specifically with a query like:: | |
| 61 | |
| 62 //Id/text() | |
| 63 | |
| 64 **XPath Expressions** | |
| 65 | |
| 66 There are many helpful tutorials on the internet for XPath expressions. | |
| 67 `Wikipedia <https://en.wikipedia.org/wiki/XPath>`__ has a number of good | |
| 68 examples. | |
| 69 | |
| 70 **Some More Examples** | |
| 71 | |
| 72 For an XML document like the following:: | |
| 73 | |
| 74 <root> | |
| 75 <a> | |
| 76 <b attr="value">1</b> | |
| 77 <b attr="none">2</b> | |
| 78 <b>3</b> | |
| 79 </a> | |
| 80 <c> | |
| 81 <d>4</d> | |
| 82 <e>5</e> | |
| 83 </c> | |
| 84 </root> | |
| 85 | |
| 86 Here are some example queries and their outputs: | |
| 87 | |
|
7
a890cac292f3
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/xpath commit 8cbc5a00fac3f19591b1f956610f0cc60810dab2
iuc
parents:
6
diff
changeset
|
88 +--------------------+---------------------------------------------------+ |
| 0 | 89 | Query | Result | |
|
7
a890cac292f3
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/xpath commit 8cbc5a00fac3f19591b1f956610f0cc60810dab2
iuc
parents:
6
diff
changeset
|
90 +====================+===================================================+ |
| 0 | 91 | //b[@attr="value"] | <b attr="value">1</b> | |
| 92 +--------------------+---------------------------------------------------+ | |
| 93 | //b[@attr] | <b attr="value">1</b><b attr="none">2</b> | | |
| 94 +--------------------+---------------------------------------------------+ | |
| 95 | //b | <b attr="value">1</b><b attr="none">2</b><b>3</b> | | |
| 96 +--------------------+---------------------------------------------------+ | |
| 97 | //b/text() | 1\n2\n3 | | |
| 98 +--------------------+---------------------------------------------------+ | |
| 99 | /root/*/*/text() | 1\n2\n3\n4\n5 | | |
| 100 +--------------------+---------------------------------------------------+ | |
| 101 | |
| 102 | |
| 103 | |
|
7
a890cac292f3
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/xpath commit 8cbc5a00fac3f19591b1f956610f0cc60810dab2
iuc
parents:
6
diff
changeset
|
104 |
| 0 | 105 @ATTRIBUTION@ |
| 106 ]]></help> | |
|
5
b88fc7f8ca73
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/xpath commit 344140b8df53b8b7024618bb04594607a045c03a
iuc
parents:
0
diff
changeset
|
107 <citations> |
|
b88fc7f8ca73
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/xpath commit 344140b8df53b8b7024618bb04594607a045c03a
iuc
parents:
0
diff
changeset
|
108 </citations> |
| 0 | 109 </tool> |
