다음을 통해 공유


Step 2: Matching Patterns (Windows Embedded CE 6.0)

1/6/2010

You can make the display more readable by creating a new XSL file that transforms the heading data in the Sales.xml file into a presentable format.

To transform the heading data

  1. Use the Copy and Paste commands to place the following text into your HTML editor.

    <?xml version="1.0"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">""""""
      <xsl:template match="/">
        <HTML>
          <HEAD>
            <TITLE><xsl:value-of select="//summary/heading"/></TITLE>
          </HEAD>
          <BODY>
            <h1><xsl:value-of select="//summary/heading"/></h1>
            <h2><xsl:value-of select="//summary/subhead"/></h2>
            <p><xsl:value-of select="//summary/description"/></p>
          </BODY>
        </HTML>
      </xsl:template>
    </xsl:stylesheet>
    
  2. Save the file as Transform.xsl*.*

  3. Open Sales.xml in your HTML editor and add the following line directly below <?xml version="1.0"?>.

    <?xml-stylesheet type="text/xsl" href="transform.xsl"?>
    

    This identifies the XSL file to be used for formatting information.

  4. Save Sales.xml.

  5. To view the file in Internet Explorer, open Sales.xml.

    The summary information for your sales report is formatted so it is easy to view.

How It Works

The xsl: lines at the beginning and end of Transform.xsl tell Internet Explorer that this is an XSL file. The XSLT parser looks for patterns in the XML data as indicated by <xsl:value-of select=. For example, select="//summary/heading" directs the parser to look for a <heading> tag that is contained in a <summary> tag. When the parser locates this pattern, the tag is formatted as an HTML <h1> tag.

See Also

Tasks

Tutorial: Getting Started with XSLT
Step 3: Looping Through Data
Step 1: Creating the Sales.xml File

Concepts

Exploring XSLT Capabilities
XSLT Developer Guide