<p dir="ltr">The key to xmlstarlet is xpath. Its the same thing you need to know to effectively use JQ. Or, with xmlstarlet, you can build a xslt file to make the transformation, then use xmlstarlet to marry the two in bash.</p>
<p dir="ltr">Good luck<br>
Kevin</p>
<br><div class="gmail_quote"><div dir="ltr">On 1:30am, Wed, Sep 12, 2018 der.hans <<a href="mailto:PLUGd@lufthans.com">PLUGd@lufthans.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Am 12. Sep, 2018 schwätzte Kevin Fries so:<br>
<br>
moin moin,<br>
<br>
I tried Xmlstarlet and it just wasn't working for me.<br>
<br>
I'll give it another go next time I need to do a transform.<br>
<br>
danke,<br>
<br>
der.hans<br>
<br>
> Xmlstarlet<br>
><br>
> <a href="http://xmlstar.sourceforge.net" rel="noreferrer noreferrer" target="_blank">http://xmlstar.sourceforge.net</a><br>
><br>
> Kevin<br>
><br>
><br>
><br>
> Sent from BlueMail <br>
><br>
> On Sep 12, 2018, 12:48 AM, at 12:48 AM, "der.hans" <<a href="mailto:plugd@lufthans.com" target="_blank" rel="noreferrer">plugd@lufthans.com</a>> wrote:<br>
>> moin moin,<br>
>><br>
>> Actually, sgrep with sed for XML :).<br>
>><br>
>> I have a chunk of XML I would like to transform. Any suggestions on how<br>
>> to<br>
>> do the following from the command line?<br>
>><br>
>> ----<br>
>> <table:table-row><br>
>> <table:table-cell table:style-name="Table1.A1"<br>
>> office:value-type="string"><br>
>> <text:p text:style-name="Standard">blah content stuff</text:p><br>
>> </table:table-cell><br>
>> <table:table-cell table:number-columns-spanned="2"<br>
>> office:value-type="string"><br>
>> <text:p text:style-name="Standard"/><br>
>> </table:table-cell><br>
>> <table:covered-table-cell/><br>
>> </table:table-row><br>
>> ----<br>
>><br>
>> I would like to make the first cell span 3 columns and wipe out the<br>
>> second<br>
>> cell.<br>
>><br>
>> The graphical tool essentially turns it into the following.<br>
>><br>
>> ----<br>
>> <table:table-row><br>
>> <table:table-cell table:style-name="Table1.A2"<br>
>> table:number-columns-spanned="3" office:value-type="string"><br>
>> <text:p text:style-name="Standard">blah content stuff</text:p><br>
>> </table:table-cell><br>
>> <table:covered-table-cell/><br>
>> </table:table-row><br>
>> ----<br>
>><br>
>> A new style, Table1.A2, is introduced. That cell is spanned across<br>
>> three<br>
>> columnts. The table:table-cell object for the second cell is removed.<br>
>><br>
>> I can do this with sed, but that invites XML issues. Also, there are<br>
>> some<br>
>> more complex changes I want to make.<br>
>><br>
>> ciao,<br>
>><br>
>> der.hans<br>
>> --<br>
>> # <a href="https://www.LuftHans.com" rel="noreferrer noreferrer" target="_blank">https://www.LuftHans.com</a> <a href="https://www.PhxLinux.org" rel="noreferrer noreferrer" target="_blank">https://www.PhxLinux.org</a><br>
>> # "Metrosexuals notwithstanding, quiche still lacks something." --<br>
>> David Brin<br>
>> ---------------------------------------------------<br>
>> PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank" rel="noreferrer">PLUG-discuss@lists.phxlinux.org</a><br>
>> To subscribe, unsubscribe, or to change your mail settings:<br>
>> <a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" rel="noreferrer noreferrer" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br>
><br>
<br>
-- <br>
# <a href="https://www.LuftHans.com" rel="noreferrer noreferrer" target="_blank">https://www.LuftHans.com</a> <a href="https://www.PhxLinux.org" rel="noreferrer noreferrer" target="_blank">https://www.PhxLinux.org</a><br>
# "Dinosaurs return. Want their oil back." -- David Brin---------------------------------------------------<br>
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank" rel="noreferrer">PLUG-discuss@lists.phxlinux.org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" rel="noreferrer noreferrer" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a></blockquote></div>