Additions:
Namespace example using xmlsh [[Namespaces]] support
declare namespace y=foo
echo "<x:a xmlns:x='foo' />" | xpath /y:a
declare namespace y=foo
echo "<x:a xmlns:x='foo' />" | xpath /y:a
Additions:
||-f,-file xpath-file|| read xpath expression from file||
||-i,-input context||(depreciated) use context as the source xml document, otherwise stdin if context is an XML expression which is an item then use it directly as the context item.||
||-c,-context context||Use context as a literal context||
||-cf,-context-file file||Use file as the name of an XML file for the context, or "-" for stdin||
||-q,-query xpath-expr||xpath expression||
||-s,-string||Convert the result to a string if it is an attribute or element||
||-b,-bool||Do not print anything. Treat the result as a boolean and exit with 0 if the value is true otherwise 1||
||-e,-exists||Execute xpath but do not print anything. The exit status is 0 if there was any selected values otherwise 1||
||-i,-input context||(depreciated) use context as the source xml document, otherwise stdin if context is an XML expression which is an item then use it directly as the context item.||
||-c,-context context||Use context as a literal context||
||-cf,-context-file file||Use file as the name of an XML file for the context, or "-" for stdin||
||-q,-query xpath-expr||xpath expression||
||-s,-string||Convert the result to a string if it is an attribute or element||
||-b,-bool||Do not print anything. Treat the result as a boolean and exit with 0 if the value is true otherwise 1||
||-e,-exists||Execute xpath but do not print anything. The exit status is 0 if there was any selected values otherwise 1||
Deletions:
-file xpath-file|| read xpath expression from file||
||-i context
-input context||(depreciated) use context as the source xml document, otherwise stdin if context is an XML expression which is an item then use it directly as the context item.||
||-c context
-context context||Use context as a literal context||
||-cf file
-context-file file||Use file as the name of an XML file for the context, or "-" for stdin||
||-q xpath-expr
-query xpath-expr|| xpath expression||
||-s
-string||Convert the result to a string if it is an attribute or element||
||-b
-bool||Do not print anything. Treat the result as a boolean and exit with 0 if the value is true otherwise 1||
||-e
-exists||Execute xpath but do not print anything. The exit status is 0 if there was any selected values otherwise 1||
No Differences
Additions:
||-i context
-input context||(depreciated) use context as the source xml document, otherwise stdin if context is an XML expression which is an item then use it directly as the context item.||
||-c context
-context context||Use context as a literal context||
||-cf file
-context-file file||Use file as the name of an XML file for the context, or "-" for stdin||
-i is depreciated. It is a convenience option that does the following
- If context is an atomic value then treat as a filename to be loaded as the context item
- Otherwise treat as the literal context for the context item
-c or -cf are suggested which explicitly indicate if to use the expression literally or as a filename
-input context||(depreciated) use context as the source xml document, otherwise stdin if context is an XML expression which is an item then use it directly as the context item.||
||-c context
-context context||Use context as a literal context||
||-cf file
-context-file file||Use file as the name of an XML file for the context, or "-" for stdin||
-i is depreciated. It is a convenience option that does the following
- If context is an atomic value then treat as a filename to be loaded as the context item
- Otherwise treat as the literal context for the context item
-c or -cf are suggested which explicitly indicate if to use the expression literally or as a filename
Deletions:
-i input||use input as the source xml document, otherwise stdin||
if input is an XML expression then use it directly (dont treat as filename).||
Additions:
If the result (or any node of the result if a sequence) is an Attribute the it is converted to a string.
Simplified example, you don't need to use /string()
xls | xpath '//file[1]/@name'
Additions:
[[Commands]]
Additions:
||-e
-exists||Execute xpath but do not print anything. The exit status is 0 if there was any selected values otherwise 1||
-exists||Execute xpath but do not print anything. The exit status is 0 if there was any selected values otherwise 1||
Deletions:
Additions:
-i input||use input as the source xml document, otherwise stdin||
if input is an XML expression then use it directly (dont treat as filename).||
if input is an XML expression then use it directly (dont treat as filename).||
Deletions:
if input is an XML expression then use it directly (dont treat as filename).||
Additions:
xpath [ [[SerializationOptions serialization options]] ] [options] [xpath-expr]
====Options====
||-f xpath-file
-file xpath-file|| read xpath expression from file||
||-input input
-i input|| use input as the source xml document, otherwise stdin||
if input is an XML expression then use it directly (dont treat as filename).||
||-n|| do not use a source context||
||-q xpath-expr
-query xpath-expr|| xpath expression||
||-v|| Read remaining pairs of arguments as name/value pairs to assign as xpath variables||
||-nons|| Do not import global namespace declarations from the shell environment||
||-ns prefix=uri|| Add a predeclared namespace delcaration||
||-s
-string||Convert the result to a string if it is an attribute or element||
||-b
-bool||Do not print anything. Treat the result as a boolean and exit with 0 if the value is true otherwise 1||
||-e||Execute xpath but do not print anything. The exit status is 0 if there was any selected values otherwise 1||
Supports the standard [ [[SerializationOptions serialization options]] ]
xls | xpath '//file[1]/@name/string()'
Result
.classpath
echo "<x:a xmlns:x='foo' />" | xpath -nons -ns y=foo /y:a
Result
====Options====
||-f xpath-file
-file xpath-file|| read xpath expression from file||
||-input input
-i input|| use input as the source xml document, otherwise stdin||
if input is an XML expression then use it directly (dont treat as filename).||
||-n|| do not use a source context||
||-q xpath-expr
-query xpath-expr|| xpath expression||
||-v|| Read remaining pairs of arguments as name/value pairs to assign as xpath variables||
||-nons|| Do not import global namespace declarations from the shell environment||
||-ns prefix=uri|| Add a predeclared namespace delcaration||
||-s
-string||Convert the result to a string if it is an attribute or element||
||-b
-bool||Do not print anything. Treat the result as a boolean and exit with 0 if the value is true otherwise 1||
||-e||Execute xpath but do not print anything. The exit status is 0 if there was any selected values otherwise 1||
Supports the standard [ [[SerializationOptions serialization options]] ]
xls | xpath '//file[1]/@name/string()'
Result
.classpath
echo "<x:a xmlns:x='foo' />" | xpath -nons -ns y=foo /y:a
Result
Deletions:
====Description====
-f xpath-file read xpath expression from file
-i input use input as the source xml document, otherwise stdin
if input is an XML expression then use it directly (dont treat as filename).
-n do not use a source context
[-q] xpath-expr xpath expression
-v Read remaining pairs of arguments as name/value pairs to assign as xpath variables
-nons Do not import global namespace declarations from the shell environment
-ns prefix=uri Add a predeclared namespace delcaration
-method output-method Changes the default output method for serialzation. Must be one of (xml,html,xhtml,text)
$ xls | xpath '//file[1]/@name'
name=".classpath"
$ echo "<x:a xmlns:x='foo' />" | xpath -nons -ns y=foo /y:a
Additions:
xpath [-f xpath-file] [-i input-file] [-n] [-nons] [-ns prefix=uri [-ns ..]] [-q] xpath-expr [-method method] [-v name value [name value ...]]
-method output-method Changes the default output method for serialzation. Must be one of (xml,html,xhtml,text)
-method output-method Changes the default output method for serialzation. Must be one of (xml,html,xhtml,text)
Deletions:
Deletions:
Additions:
[[CommandsInternal]]
Additions:
Namespace example using a renamed prefix for a namespace
$ echo "<x:a xmlns:x='foo' />" | xpath -nons -ns y=foo /y:a
<x:a xmlns:x="foo"/>
$ echo "<x:a xmlns:x='foo' />" | xpath -nons -ns y=foo /y:a
<x:a xmlns:x="foo"/>
Additions:
xpath [-f xpath-file] [-i input-file] [-n] [-nons] [-ns prefix=uri [-ns ..]] [-q] xpath-expr [-v name value [name value ...]]
-nons Do not import global namespace declarations from the shell environment
-ns prefix=uri Add a predeclared namespace delcaration
-nons Do not import global namespace declarations from the shell environment
-ns prefix=uri Add a predeclared namespace delcaration
Deletions:
Additions:
xpath [-f xpath-file] [-i input-file] [-n] [-q] xpath-expr [-v name value [name value ...]]
if input is an XML expression then use it directly (dont treat as filename).
-n do not use a source context
[-q] xpath-expr xpath expression
Note that the "-q" is optional. It is only required if you need to specify both -n and -v
Examples
xpath-n -q expr -v variable some-value
Returns 0 if the the xpath expression executed successfully and a non-empty result is returned. otherwise 1
if input is an XML expression then use it directly (dont treat as filename).
-n do not use a source context
[-q] xpath-expr xpath expression
Note that the "-q" is optional. It is only required if you need to specify both -n and -v
Examples
xpath-n -q expr -v variable some-value
Returns 0 if the the xpath expression executed successfully and a non-empty result is returned. otherwise 1
Deletions:
if input is an XML expression then use it directly (dont treat as filename).
-n do not use a source context
xpath-expr xpath expression
Returns 0 if the the xpath expression executed successfully. otherwise 1
Additions:
xpath [-f xpath-file] [-i input-file] [-n] xpath-expr [-v name value [name value ...]]
-i input use input as the source xml document, otherwise stdin
if input is an XML expression then use it directly (dont treat as filename).
-v Read remaining pairs of arguments as name/value pairs to assign as xpath variables
-i input use input as the source xml document, otherwise stdin
if input is an XML expression then use it directly (dont treat as filename).
-v Read remaining pairs of arguments as name/value pairs to assign as xpath variables
Deletions:
-i input-file use input-file as the source xml document, otherwise stdin
Additions:
Returns 0 if the the xpath expression executed successfully. otherwise 1
----
[[CategoryCommands]]
----
[[CategoryCommands]]
Deletions:
Additions:
xpath-expr xpath expression
Returns 0 if the the xpath expression executed successfully. otherwise 1
Returns 0 if the the xpath expression executed successfully. otherwise 1
Deletions:
Additions:
xpath [-f xpath-file] [-i input-file] [-n] xpath-expr
-f xpath-file read xpath expression from file
-i input-file use input-file as the source xml document, otherwise stdin
-n do not use a source context
====Example====
%%(shell)
$ xls | xpath '//file[1]/@name'
name=".classpath"
%%
-f xpath-file read xpath expression from file
-i input-file use input-file as the source xml document, otherwise stdin
-n do not use a source context
====Example====
%%(shell)
$ xls | xpath '//file[1]/@name'
name=".classpath"
%%