Monday, July 11, 2016

Sample XML XSLT

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

    <xsl:template match="data">
        <link href="/bootstrap/css/bootstrap.min.css" type="text/css" rel="stylesheet"/>
        <table class="table table-bordered table-condensed table-striped">
            <xsl:apply-templates/>
        </table>
    </xsl:template>

    <xsl:template match="titles">
        <tr>
          <xsl:apply-templates mode="header"/>
        </tr>    
    </xsl:template>

    <xsl:template match="row" name="standardRow">
        <tr>
          <xsl:apply-templates/>
        </tr>
    </xsl:template>

    <xsl:template match="row/*">
        <td>
          <xsl:apply-templates select="node()"/>
        </td>
    </xsl:template>

    <xsl:template match="title" mode="header">
        <th>
          <xsl:value-of select="node()"/>
        </th>
    </xsl:template>

</xsl:stylesheet>

<?xml version="1.0"?>

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


<data>

    <titles>
        <title>Pangalan</title>
        <title>Apelyido</title>    
    </titles>


    <rows>

        <row><Lastname>Abbas</Lastname><FirstName>Syed</FirstName></row>
        <row><Lastname>Abel</Lastname><FirstName>Catherine</FirstName></row>
        <row><Lastname>Abercrombie</Lastname><FirstName>Kim</FirstName></row>

        
    </rows>

</data>


No comments:

Post a Comment