Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" &gt; &lt;xsl:output method="xml" indent="yes"/&gt; &lt;xsl:template match="@*|node()"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="@*|node()"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="varinfo"&gt; &lt;xsl:copy&gt; &lt;xsl:copy-of select="vardef/name"/&gt; &lt;size&gt; &lt;xsl:value-of select="8 *count( descendant::singleinit[ contains(.,'(unsigned char)') ] ) + 16 * count( descendant::singleinit[ contains(.,'(short)') ] ) + 32 *count( descendant::singleinit[ contains(.,'(uint32 const volatile)' ) ] )"/&gt; &lt;/size&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>Which will generate the following output:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;variablelist&gt; &lt;varinfo&gt;&lt;name&gt;A&lt;/name&gt;&lt;size&gt;112&lt;/size&gt;&lt;/varinfo&gt; &lt;varinfo&gt;&lt;name&gt;B&lt;/name&gt;&lt;size&gt;128&lt;/size&gt;&lt;/varinfo&gt; &lt;varinfo&gt;&lt;name&gt;C&lt;/name&gt;&lt;size&gt;224&lt;/size&gt;&lt;/varinfo&gt; &lt;/variablelist&gt; </code></pre> <p>Comment: According your request: <em>For transformation of the strings to my numbers I would use something like this</em> (some xsl:when for bit size). I do not recommend that. This will only make things more complicated. Possible enhancements depending on your final solutions are:<br> - Move the calculation into are named template.<br> - adapt the contains operation that it dose not distinguish between signed and unsigned.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload