Monthly Archives: May 2015

The most useful shortcut key almost no one knows

Have you ever closed a browser tab and a second later it turned out that was the one you needed?  Ctrl-Shift-T allows you to reopen your most recently closed tab in Firefox, Chrome, and Internet Explorer.  When I first learned of this trick, I was surprised there was no obvious menu that provided the function, but it turns out that this is one of my favorite shortcuts.

A Few of My Favorite XSLTs

Convert all tag names to lower case

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" >
<xsl:output exclude-result-prefixes="xsl xs" indent="yes"/>

  <xsl:template match="*">      
  <xsl:element name="{translate(local-name(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')}">
        <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>    

</xsl:stylesheet>

Remove all namespaces

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>

<xsl:template match="/|comment()|processing-instruction()">
    <xsl:copy>
      <xsl:apply-templates/>
    </xsl:copy>
</xsl:template>

<xsl:template match="*">
    <xsl:element name="{local-name()}">
      <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
</xsl:template>

<xsl:template match="@*">
    <xsl:attribute name="{local-name()}">
      <xsl:value-of select="."/>
    </xsl:attribute>
</xsl:template>
</xsl:stylesheet>

Convert all Attributes into Elements

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output  indent="yes" />
  <xsl:strip-space elements="*"/>
  <xsl:template match="/*/*/*">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:for-each select="*">
        <xsl:attribute name="{name()}">
          <xsl:value-of select="."/>
        </xsl:attribute>
      </xsl:for-each>
    </xsl:copy>
  </xsl:template>
  <xsl:template match="node()">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates select="node() | text()"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
Tagged