E-Tip
 2011.10.03
 2011.10.10
 2011.10.17
 2011.10.24
 2011.10.31
 2011.11.07
 2011.11.21
 2011.11.28
 2011.12.05
 2011.12.19
 2011.12.26
â–¶view 2012

Place a search on your website for freé
Adding a search engine to your website can cost a small fortune if you don’t shóp around. Fortunately, we have two solutions for obtaining a freé search. Atomz Corporation, www.atomz.com, offers the Atomz Express Search. It’s a freé commercial solution that you can implement in just a few minutes. To learn more about the Atomz Express Search check out www.atomz.com/applications/search/trial.htm. Another freé search solution is on Bravenet's site at www.bravenet.com/webtools/search2/index.php. You can try either of these resources for freé and if later you wish decide that you need a larger search you can upgrade.


Make the case of your element and attribute names consistent with XSLT
A common use of the XSLT translate() function is to change the case of text strings within a document; however, you may run into situations where you need to change the actual element and attribute name cases, not simply text strings within them.

For instance, you may receive well-formed XML submissions from multiple sources which use the same element/attribute names, but one may use uppercase, another upper-lower, and another all lowercase. Or you may be trying to integrate data from disparate XML data sets and need to change the case for consistency across tag names.

You can use the XSLT translate() function to do this for you. The XSLT stylesheet below is a standalone process that converts one XML document into another, changing the case of all elements and attributes from uppercase to lowercase.

<?xml version="1.0" encoding="UTF-8"?>

<!-- XSLT to transform all element/attribute names to lowercase -->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

   <xsl:output method="xml" encoding="UTF-8" version="1.0" />
   
   <xsl:template matçh="*">

      <xsl:variable name="vElement"
          select="translate(name(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')" />

      <xsl:element name="{$vElement}">
         <xsl:for-each select="@*">
            <xsl:variable name="vAttribute"
                select="translate(name(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')" />
            <xsl:attribute name="{$vAttributename}"><xsl:value-of select="."/></xsl:attribute>
         </xsl:for-each>
         <xsl:apply-templates />
      </xsl:element>
   </xsl:template>

</xsl:stylesheet>

The output method is, of course, XML. Note that only one template is required. Use the template to matçh on any element. Then, set a local variable to pick up the element name, matçh all uppercase letters in the name, and replace them with lowercase letters. Next, for each element, matçh on any attributes, create a new local variable, and apply the same translate rule to attribute names. Finally, apply templates to output the transformed element and attribute names.

The resulting XML file will now have lowercase names for all elements and attributes. All text and attribute contents will pass through intact.