xslt: operations on new elements

Posted by user1495523 on Stack Overflow See other posts from Stack Overflow or by user1495523
Published on 2013-10-18T03:46:26Z Indexed on 2013/10/18 3:53 UTC
Read the original article Hit count: 114

Filed under:
|

Could you please explain in case we could perform any operations on newly included elements using xsl?
To explain using an example: if we have the following input file

<?xml version="1.0" encoding="UTF-8"?>
<top>
    <Results>
        <a>no</a>
        <b>10</b>
        <c>12</c>
        <d>9</d>
    </Results>
    <Results>
        <a>Yes</a>
        <b>8</b>
        <c>50</c>
        <d>12</d>
    </Results>
</top>

We need the final result as

<?xml version="1.0" encoding="UTF-8"?>
<top>
    <Results>
        <a>no</a>
        <b>10</b>
        <b_>10</b_>
        <c>12</c>
        <c_>12</c_>
        <d>9</d>
        <e_>11</e_>
    </Results>
    <Results>
        <a>Yes</a>
        <b>8</b>
        <b_>8</b_>
        <c>50</c>
        <c_>50</c_>
        <d>12</d>
        <e_>29</e_>
    </Results>
</top>

Where:
b_ = b,
c_ = c,
&
e_ = (b_ + c_)/2

© Stack Overflow or respective owner

Related posts about Xml

Related posts about xslt