Why does this XSL fails to retrieve value from xml ?

Posted by Pavitar on Stack Overflow See other posts from Stack Overflow or by Pavitar
Published on 2010-12-26T11:26:38Z Indexed on 2010/12/26 17:53 UTC
Read the original article Hit count: 284

Filed under:
|
|
|

Following is an extract of the XSL stylesheet that I have written. It says my '.xsl' is well formed but it somehow does not retrieve values from the xml,instead jus pastes the header and table headings.

EDIT

    <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">

<xsl:template match="/" >
    <html>
        <head>
            <title>GlenMark Pharma</title>
        </head>
        <h1 align="center"><font face="Monotype Corsiva" color="red">GlenMarkPharma</font></h1>
        <body>
            <table>
                <tbody>
                    <tr>
                        <th>ID</th>
                        <th>ENAME</th>
                        <th>Mobile</th>
                        <th>EMAIL</th>
                        <th>PWD</th>
                    </tr>
                    <xsl:for-each select="employees/employee">
                        <tr>
                            <td><xsl:value-of select="@empID" /></td>
                            <td><xsl:value-of select="name" /></td>
                            <td><xsl:value-of select="mobile" /></td>
                            <td><xsl:value-of select="email" /></td>
                            <td><xsl:value-of select="pwd" /></td>
                        </tr>
                    </xsl:for-each>
                </tbody>
            </table>
        </body>
    </html>
</xsl:template>
</xsl:stylesheet>

Here is my XML doc:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="MyfirstXsl.xsl"?>
<!DOCTYPE employees SYSTEM "Mydtd.dtd">
<me:employees xmlns:me="[email protected]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="[email protected] Mycomplex.xsd">
    <me:employee empID="EMP101">
        <me:name>Vicky</me:name>
        <me:mobile>9870582356</me:mobile>
        <me:email>[email protected]</me:email>
        <me:pwd>&defPWD;</me:pwd>
    </me:employee>
</me:employees>

I have also tried writing:

<xsl:for-each select="employees/employee">
                        <tr>
                            <td><xsl:value-of select="@empID" /></td>
                            <td><xsl:value-of select="me:name" /></td>

in the XSL since I have an alias to the namespace in my XML Doc.But it gives me an error of Invalid Pre-fix.I don't know what I'm doing wrong.

© Stack Overflow or respective owner

Related posts about Xml

Related posts about xslt