Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Consider the following stylesheet:</p> <pre><code>&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:strip-space elements="*"/&gt; &lt;xsl:key name="getHeaderText" match="report_header/*" use="local-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:element name="{ translate( key('getHeaderText', local-name()), ' ', '_') }"&gt; &lt;xsl:apply-templates/&gt; &lt;/xsl:element&gt; &lt;/xsl:template&gt; &lt;xsl:template match="report_header"/&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>Applied to an XML with spaces in headers:</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>It produces this result:</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>
    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. This table or related slice is empty.
    1. 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