Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 21st, 2005, 07:39 AM
pkg pkg is offline
Registered User
 
Join Date: Jun 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT HELP URGENT!

Hi
I have an xml file:
==============================
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="overview.xsl"?>
<ThingsDispatchProcessRequest xmlns="http://webui.things/util/webservice">
    <session>One</session>
    <result>
        <header name="Statistics">
            [list]

                <li>20 imports runned since 20 january 2004(registry date)</li>

                <li>105 THINGS</li>

                <li>in 5 categories</li>

                <li>consisting of 482 unique elements</li>

                <li>with 8937539875 elementvalues</li>

            </ul>

        </header>

        <header name="BMail">

            <p>You have no new messages</p>

        </header>

        <header name="Things News">

            [list]

                <li>News Item #1</li>

                <li>News Item #2</li>

                <li>News Item #3</li>

            </ul>

        </header>

    </result>

</ThingsDispatchProcessRequest>
================================
I have written an xslt to convert it into html but nothing works
================================================== ===============
my xslt:
===============================================
<?xml version="1.0" encoding="UTF-8"?>



<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:x="http://webui.things/util/webservice">



    <xsl:output method="html"/>



    <xsl:template match="/">

    <html>

        <head>

            <title>THINGS.network Supplier</title>

            <link rel="stylesheet" type="text/css" href="default.css"/>

        </head>

        <body>

            <div class="box">
                <h2>Overview</h2>


                <h3><xsl:value-of select="/ThingsDispatchProcessRequest/result/header[1]/@name"/></h3>
                <div class="item">
                    <ul class="nobullets">
                        <xsl:for-each select="/ThingsDispatchProcessRequest/result/header[1]/ul/li">
                            <li><xsl:value-of select="."/></li>
                        </xsl:for-each>
                    </ul>
                </div>


                <h3><xsl:value-of select="/ThingsDispatchProcessRequest/result/header[2]/@name"/></h3>
                <div class="item">
                    <ul class="nobullets">
                        <li><xsl:value-of select="/ThingsDispatchProcessRequest/result/header[2]/p"/></li>
                    </ul>
                </div>


                <h3><xsl:value-of select="/ThingsDispatchProcessRequest/result/header[3]/@name"/></h3>
                <div class="item">
                    <ul class="nobullets">
                        <xsl:for-each select="/ThingsDispatchProcessRequest/result/header[3]/ul/li">
                            <li><xsl:value-of select="."/></li>
                        </xsl:for-each>
                    </ul>
                </div>
            </div>

        </body>

    </html>

    </xsl:template>

</xsl:stylesheet>
==================
Only Overview is shown in the html output
Please help me

 
Old June 21st, 2005, 08:02 AM
Authorized User
 
Join Date: Jul 2004
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You are missing the namespace alias (x) in your xpath statements:

<xsl:value-of select="/x:ThingsDispatchProcessRequest/x:result/x:header[1]/@name"/>

Your stylesheet seems quite repetitive, how about:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:x="http://webui.things/util/webservice">
    <xsl:output method="html"/>

    <xsl:template match="/">
        <html>
            <head>
                <title>THINGS.network Supplier</title>
                <link rel="stylesheet" type="text/css" href="default.css"/>
            </head>
            <body>
                <div class="box">
                    <h2>Overview</h2>

                    <xsl:apply-templates select="/x:ThingsDispatchProcessRequest/x:result/x:header" />
                </div>
            </body>
        </html>
    </xsl:template>

    <xsl:template match="x:header">
        <h3><xsl:value-of select="@name"/></h3>
        <div class="item">
            <ul class="nobullets">
                   <xsl:apply-templates />
            </ul>
        </div>
    </xsl:template>

    <xsl:template match="x:ul">
        <xsl:apply-templates />
    </xsl:template>

    <xsl:template match="x:li">
        <li><xsl:apply-templates /></li>
    </xsl:template>

    <xsl:template match="x:p">
        <li><xsl:apply-templates /></li>
    </xsl:template>

</xsl:stylesheet>

 
Old June 21st, 2005, 08:14 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You have declared xmlns="thing" in your source doc, so all your names are in a namespace. In the stylesheet you need to declare xmlns:x="thing" and match the names as select="x:local-name" or match="x:local-name".

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 22nd, 2005, 01:46 AM
pkg pkg is offline
Registered User
 
Join Date: Jun 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you barcher and Michael Kay for you valuable suggestions.
:)






Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT Function very urgent alapati.sasi XSLT 3 May 23rd, 2007 03:45 AM
doubt in XSLT -- very urgent subbukns XSLT 1 May 21st, 2007 05:10 PM
Query About XSLT-Urgent harshalchoksi XSLT 6 February 23rd, 2007 06:43 AM
urgent help with xslt sonya9879 XSLT 1 August 18th, 2005 09:17 AM
How to create forms with XSLT- urgent hums XSLT 0 September 13th, 2004 04:47 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.