0

I have some xml that looks like this in each report:

Header
Cell
/Cell
Cell
/Cell
...
/Header

In each cell I need to add:

                <property name="borderBottomColor">#E1E1E1</property>
                <property name="borderBottomStyle">solid</property>
                <property name="borderBottomWidth">thin</property>

This will take me about a week to do manually.

Is there a tool that could do this?

Thanks

1
  • What about using your favourite editor (vim, emacs, …) and a custom macro?
    – Marco
    Sep 11, 2012 at 15:04

2 Answers 2

0

You can try XMLStarlet - an open source, command-line XML editor.

It allows you for example to add or update nodes in an XML document. Which nodes are updated can be specified by an XPath expression.

0

It's hard to give an exact answer without actual sample XML input (and a full output example), but you could use XSLT

XSLT 1.0

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output indent="yes"/>
    <xsl:strip-space elements="*"/>

    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="Cell">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>           
            <property name="borderBottomColor">#E1E1E1</property>
            <property name="borderBottomStyle">solid</property>
            <property name="borderBottomWidth">thin</property>
        </xsl:copy>
    </xsl:template>

</xsl:stylesheet>

You could run this with Xalan or Saxon from the command line.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .