The Extremist Threat to American Democratic Culture – SWR und Fraunhofer IOSB aus Karlsruhe proben in Heidenheim die Totalüberwachung
YML feature of the day: XPath command line
Hello,
today I'm starting my new "feature of the day" series. This time: XPath command line.
yml2proc is a handy tool to
use YML 2 interactively. But it can do more: with the command line switch
-e
it executes XPath expressions directly from the command line:
% yml2proc -Me '23*42'
966.0
% _
This can be very handy to search in XML or YML documents. Let's say, we have an XML file like this:
% head -n 20 sequence.xcg
<?xml version="1.0"?>
<CodeGen xmlns:UML="http://schema.omg.org/spec/UML/1.3"
xmlns:CodeGen="http://fdik.org/schemas/CodeGen.xsd"
version="1.3">
<source-file>/Users/vb/mico/test/idl/11/sequence.idl</source-file>
<!--
* MICO: an Open Source CORBA implementation
* Copyright (c) 1997-2006 by The Mico Team
* Copyright (c) 2007-2010 by Volker Birk
*
* This file was automatically generated. DO NOT EDIT!
-->
<Struct name="S">
<field name="x">
<type stereotype="Base">long</type>
</field>
<field name="seq">
<type stereotype="Sequence">sequence< long ></type>
</field>
</Struct>
<Sequence name="SSeq" boxing="/CodeGen/*[@name='S']"
bstereotype="VariableStruct"/>
<Sequence name="StringSeq" boxing="string" bstereotype="Base"/>
% _
Then searching that file is such easy:
% yml2proc -e '//Struct[@name="S"]/field[@name="seq"]/type' \
-x sequence.xcg
<type xmlns:UML="http://schema.omg.org/spec/UML/1.3"
xmlns:CodeGen="http://fdik.org/schemas/CodeGen.xsd"
stereotype="Sequence">sequence< long ></type>
% _
This works for YML files, too:
% yml2proc -e '//func[@name="f"]' yml2/samples/clike.yml2 |
yml2proc -Y
func type="void", name="f" {
parm {
in;
string;
x;
}
parm {
out;
long;
y;
}
}
% _