Ramesh Chandran
Ramesh Chandran

Reputation: 11

How to Assign xsl expression result to a xml attribute

I am trying modify existing table( with table formula ) of Open office writer document's content.xml through XSLT.

The table formula is a attribute value as table:formula="ooow:sum<A1:C1>". When the node is presented inside xsl: for-each, the row value is increased(in the output XML) up to the no-of elements of the source XML. so the formula always refers only the first row values in result XML. I want to modify the cell reference through the XSLT expression.

<xsl:for-each select="some xpath">
<table:table-row>
    <table:table-cell table:style-name="Table1.A1"><text:p text:style-name="Table_20_Contents">10</text:p></table:table-cell>
    <table:table-cell table:style-name="Table1.B1"><text:p text:style-name="Table_20_Contents">5</text:p></table:table-cell>
    <table:table-cell table:style-name="Table1.C1"><text:p text:style-name="Table_20_Contents">7</text:p></table:table-cell>
    <table:table-cell table:style-name="Table1.D1" office:value="1.79769313486232E+308" office:value-type="float" table:formula="ooow:sum<A1:C1>">
        <text:p text:style-name="Table_20_Contents">22</text:p>
    </table:table-cell>
</table:table-row>

How can we assign xslt expression like

concat('ooow:sum A',position(), ':C', position(), '>') to XML attribute

kindly help me, Thanks in advance.

Upvotes: 1

Views: 380

Answers (1)

Ian Roberts
Ian Roberts

Reputation: 122374

Use an attribute value template, wrapping the expression in braces:

<table:table-cell table:style-name="Table1.D1" office:value="1.79769313486232E+308"
   office:value-type="float" table:formula="{concat(....)}">

Upvotes: 1

Related Questions