#14 Renaming tag in Openoffice document fails

closed
nobody
5
2011-02-15
2011-02-14
No

Hi,

I am trying to fix an openoffice document by replacing certain text:h tags with text:p tags.
The document I try to fix is
> http://forge.typo3.org/projects/extension-formhandler/repository/raw/trunk/doc/manual-full.sxw
and can be just unzipped. The file content.xml is the one I'm working on, after xmllint --format'ing it.

So far I tried to use
$ xmlstarlet ed --rename 'text:h[@text:style-name="P39" AND @text:level="1"]' -v 'text:p' content.xml > fixed.xml
and
$ xmlstarlet ed --rename 'text:h' -v 'text:p' content.xml > fixed.xml
but after running that, content.xml and fixed.xml are the same. That's with xmlstarlet 1.0.5.

So my question is: What am I doing wrong? What's the correct way to rename that tag?

Discussion

  • Christian Weiske

    I just see that I my commands already include the namespace definition and I forgot to paste them:
    $ xmlstarlet ed -N text=http://openoffice.org/2000/text --rename 'text:h[@text:style-name="P39" and @text:level="1"]' -v 'text:p' content.xml > fixed.xml
    and
    $ xmlstarlet ed -N text=http://openoffice.org/2000/text --rename 'text:h' -v 'text:p' content.xml > fixed.xml

     
  • Noam Postavsky

    Noam Postavsky - 2011-02-14

    First of all you need //text:h[...] because you want to match against text:h elements anywhere in the tree. Second it appears that aren't in fact any text:h elements with style P39 and level 1:

    > xml sel --text -N text=http://openoffice.org/2000/text -t -m "//text:h[@text:style-name='P39']" -o level= -v @text:level --nl content.xml
    level=2
    level=2
    level=2
    level=2
    level=2
    level=2
    level=2
    level=2
    level=2
    level=2
    level=2
    level=2
    level=2

     
  • Noam Postavsky

    Noam Postavsky - 2011-02-14
    • status: open --> pending
     
  • Christian Weiske

    Noam, it was indeed the "//" missing - thanks for the hint.

    And about the not existing level1 attributes, I had another version of the file here that I manually modified already.

     
  • Christian Weiske

    • status: pending --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks