Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Name

XmlTransform

Synopsis

                   XmlTransform(XmlString|XmlDocObj, XslString)

Performs an XSLT (eXtensible Stylesheet Language Transformation) on an XML string or document object using an XSL (eXtensible Style Language) string. The results are returned as a string. The following example reads in an XML document containing employee names and titles:

<?xml version='1.0' standalone='yes'?>
<company>
  <employee>
    <name>Pere Money</name>
    <title>President</title>
  </employee>
  <employee>
    <name>Aaron Ridge</name>
    <title>Analyst</title>
  </employee>
  <employee>
    <name>Martin Grant</name>
    <title>Manager</title>
  </employee>
</company>

The example then reads in a simple XSL file for formatting the XML as HTML:

<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  version="1.0">
  <xsl:output method="html"/>
          
  <xsl:template match="/company">
    <html>
      <head>
        <title>Employees</title>
      </head>
      <body>
      <table border="1"> 
        <tr>
          <th>Name</th>
          <th>Title</th>
        </tr>
      <xsl:apply-templates select="employee"/>
      </table>
      </body>
    </html>
  </xsl:template>
  
  <xsl:template match="employee">
    <tr>
      <td><xsl:value-of select="name"/></td>
      <td><xsl:value-of select="title"/></td>
    </tr>
  </xsl:template>
</xsl:stylesheet>

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint