简体   繁体   中英

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.

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(....)}">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM