I've got an svg that contains the following (trimmed down):
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape">
<g
inkscape:label="base"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-600)">
<image
sodipodi:absref="/Untitled.png"
xlink:href="/Untitled.png"
width="800"
height="500"
preserveAspectRatio="none"
id="image5168"
x="3.67"
y="596" />
</g>
<g
inkscape:groupmode="layer"
id="layer30"
inkscape:label="triangle">
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 273,340 290,127 563,307 Z"
id="path5174"
inkscape:connector-curvature="0" />
</g>
</svg>
When I query with:
xmlstarlet sel -t -v "//_:svg/_:g/@inkscape:label" drawing.svg
I get:
base
triangle
I've been digging through the conditionals, but I can't find a way to select g
's inkscape:label
only if it contains a path
node [or otherwise, if it doesn't contain an image
node].
To get only
g
that has childpath
, you can simply addpath
in a predicate forg
: