Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>This transformation</strong>:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output omit-xml-declaration="yes" indent="yes"/&gt; &lt;xsl:strip-space elements="*"/&gt; &lt;xsl:variable name="vAlphanum" select= "concat('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz', '_0123456789' ) "/&gt; &lt;xsl:variable name="vReps" select= "'_____________________________________'"/&gt; &lt;xsl:key name="kColNameByCode" match="report_header/*/text()" use="name(..)"/&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="report_row/*"&gt; &lt;xsl:variable name="vNameText" select= "key('kColNameByCode', name())"/&gt; &lt;xsl:variable name="vElName" select= "translate($vNameText, translate($vNameText,$vAlphanum,''), $vReps) "/&gt; &lt;xsl:element name="{$vElName}"&gt; &lt;xsl:value-of select="."/&gt; &lt;/xsl:element&gt; &lt;/xsl:template&gt; &lt;xsl:template match="report_header"/&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>when applied to the provided XML document</strong>:</p> <pre><code>&lt;report&gt; &lt;report_header&gt; &lt;c1&gt;desc&lt;/c1&gt; &lt;c2&gt;pr name&lt;/c2&gt; &lt;c3&gt;pr num&lt;/c3&gt; &lt;c4&gt;cdate&lt;/c4&gt; &lt;c5&gt;phase&lt;/c5&gt; &lt;c6&gt;stype&lt;/c6&gt; &lt;c7&gt;status&lt;/c7&gt; &lt;c8&gt;parent&lt;/c8&gt; &lt;c9&gt;location&lt;/c9&gt; &lt;/report_header&gt; &lt;report_row&gt; &lt;c1&gt;&lt;/c1&gt; &lt;c2&gt;IT Project Message Validation&lt;/c2&gt; &lt;c3&gt;IT-0000021&lt;/c3&gt; &lt;c4&gt;12/14/2010 09:56 AM&lt;/c4&gt; &lt;c5&gt;Preparation&lt;/c5&gt; &lt;c6&gt;IT Projects&lt;/c6&gt; &lt;c7&gt;Active&lt;/c7&gt; &lt;c8&gt;IT&lt;/c8&gt; &lt;c9&gt;/IT/BIOMED&lt;/c9&gt; &lt;/report_row&gt; &lt;report_row&gt; &lt;c1&gt;&lt;/c1&gt; &lt;c2&gt;David, Michael John Morning QA Test&lt;/c2&gt; &lt;c3&gt;IT-0000020&lt;/c3&gt; &lt;c4&gt;12/14/2010 08:12 AM&lt;/c4&gt; &lt;c5&gt;Preparation&lt;/c5&gt; &lt;c6&gt;IT Projects&lt;/c6&gt; &lt;c7&gt;Active&lt;/c7&gt; &lt;c8&gt;IT&lt;/c8&gt; &lt;c9&gt;/IT/BIOMED&lt;/c9&gt; &lt;/report_row&gt; &lt;/report&gt; </code></pre> <p><strong>produces the wanted, correct result</strong>:</p> <pre><code>&lt;report&gt; &lt;report_row&gt; &lt;desc/&gt; &lt;pr_name&gt;IT Project Message Validation&lt;/pr_name&gt; &lt;pr_num&gt;IT-0000021&lt;/pr_num&gt; &lt;cdate&gt;12/14/2010 09:56 AM&lt;/cdate&gt; &lt;phase&gt;Preparation&lt;/phase&gt; &lt;stype&gt;IT Projects&lt;/stype&gt; &lt;status&gt;Active&lt;/status&gt; &lt;parent&gt;IT&lt;/parent&gt; &lt;location&gt;/IT/BIOMED&lt;/location&gt; &lt;/report_row&gt; &lt;report_row&gt; &lt;desc/&gt; &lt;pr_name&gt;David, Michael John Morning QA Test&lt;/pr_name&gt; &lt;pr_num&gt;IT-0000020&lt;/pr_num&gt; &lt;cdate&gt;12/14/2010 08:12 AM&lt;/cdate&gt; &lt;phase&gt;Preparation&lt;/phase&gt; &lt;stype&gt;IT Projects&lt;/stype&gt; &lt;status&gt;Active&lt;/status&gt; &lt;parent&gt;IT&lt;/parent&gt; &lt;location&gt;/IT/BIOMED&lt;/location&gt; &lt;/report_row&gt; &lt;/report&gt; </code></pre> <p><strong>Do note</strong>:</p> <ol> <li><p><strong>The transformation successfully converts any text with any number of different non-alphanumeric characters</strong> to a syntactically-correct XML name.</p></li> <li><p><strong>Efficiency is achieved</strong> using keys.</p></li> </ol>
 

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