sed for XML

James Mcphee jmcphe at gmail.com
Wed Sep 12 10:45:51 MST 2018


And let's not forget, parsing markup with regex summons cthulu.
https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454

On Wed, Sep 12, 2018 at 10:29 AM Joseph Sinclair <plug-discussion at stcaz.net>
wrote:

> This is what XSLT is for.
> You can run XSLT transforms from the command line with xsltproc (apt-get
> xsltproc)
> XSLT language, is a topic of its own, but it is a functional language very
> much like lisp, except task-specific to transforming xml documents.
>
> On 2018-09-11 11:48 PM, der.hans wrote:
> > moin moin,
> >
> > Actually, sgrep with sed for XML :).
> >
> > I have a chunk of XML I would like to transform. Any suggestions on how
> to
> > do the following from the command line?
> >
> > ----
> >     <table:table-row>
> >      <table:table-cell table:style-name="Table1.A1"
> > office:value-type="string">
> >       <text:p text:style-name="Standard">blah content stuff</text:p>
> >      </table:table-cell>
> >      <table:table-cell table:number-columns-spanned="2"
> > office:value-type="string">
> >       <text:p text:style-name="Standard"/>
> >      </table:table-cell>
> >      <table:covered-table-cell/>
> >     </table:table-row>
> > ----
> >
> > I would like to make the first cell span 3 columns and wipe out the
> second
> > cell.
> >
> > The graphical tool essentially turns it into the following.
> >
> > ----
> >     <table:table-row>
> >      <table:table-cell table:style-name="Table1.A2"
> > table:number-columns-spanned="3" office:value-type="string">
> >       <text:p text:style-name="Standard">blah content stuff</text:p>
> >      </table:table-cell>
> >      <table:covered-table-cell/>
> >     </table:table-row>
> > ----
> >
> > A new style, Table1.A2, is introduced. That cell is spanned across three
> > columnts. The table:table-cell object for the second cell is removed.
> >
> > I can do this with sed, but that invites XML issues. Also, there are some
> > more complex changes I want to make.
> >
> > ciao,
> >
> > der.hans
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.phxlinux.org/mailman/listinfo/plug-discuss



-- 
James McPhee
jmcphe at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.phxlinux.org/pipermail/plug-discuss/attachments/20180912/dfa54e9b/attachment.html>


More information about the PLUG-discuss mailing list