Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP XML Using ASP 3 and XML. See also the XML category for more XML discussions not relating to ASP. NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP XML 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 January 8th, 2004, 11:43 PM
Registered User
 
Join Date: Jan 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Professional ASP XML Book

I am trying to learn xml/xsl using wrox's Professional ASP XML book.

I am having trouble in chapter 8 trying to perform transformations.

Here is my code:

[XML]
<?xml version="1.0" encoding="utf-8" ?>
<contact_info>
    <business>
        <contact>
            <name>Jon Doe</name>
            <phone>555-5319</phone>
        </contact>
    </business>
    <personal>
        <contact relation="family">
            <name>Mary Jones</name>
            <phone>555-9013</phone>
        </contact>
        <contact>
            <name>Mike Wilson</name>
            <phone>555-4138</phone>
        </contact>
    </personal>
</contact_info>

[XSL]
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

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

    <xsl:template match="/contact_info">
        <html>
            <body>
                <xsl:apply-templates />
            </body>
        </html>
    </xsl:template>

    <xsl:template match="contact_info">
        <xsl:for-each select="./*">
            <xsl:choose>
                <xsl:when test=".[.!nodeName()='personal']">
                    <div style="background-color:teal; color:white; font-family:verdana, arial; font-size:12pt; padding:2px;">Personal Contacts</div>
                </xsl:when>
                <xsl:otherwise>
                    <div style="background-color:black; color:white; font-family:verdana, arial; font-size:12pt; padding:2px;">Business Contacts</div>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:apply-templates />
        <p />
        </xsl:for-each>
    </xsl:template>

    <xsl:template match="contact">
        <xsl:for-each select=".">
            <div>
                <xsl:if test="@relation[.!value()='family']">
                    <xsl:attribute name="style">font-weight:bold;</xsl:attribute>
                </xsl:if>
                <xsl:value-of select="name" />
                    <div style="font-size:10pt; left:.25cm; position:relative;">
                        <xsl:value-of select="phone" />
                    </div>
            </div>
        </xsl:for-each>
    </xsl:template>

</xsl:stylesheet>

[VBS]
<%@ Language="VBSCRIPT"%>
<%
    Dim pDoc, pStyle, sHtml

    Set pDoc = Server.CreateObject("Microsoft.XmlDom")
    Set pStyle = Server.CreateObject("Microsoft.XmlDom")

    If Not pDoc Is Nothing And Not pStyle Is Nothing Then
        pDoc.async = False
        pStyle.async = False
        pDoc.Load(Server.MapPath("Contacts.xml"))
        pStyle.Load(Server.MapPath("Contacts.xslt"))

        If Not pDoc.parseError And Not pStyle.parseError Then
            sHtml = pDoc.transformNode(pStyle)
            Response.Write(sHrml)
        Else
            Response.Write("Parser error")
        End If
    Else
        Response.Write("Error creating Xml objects")
    End If
%>

When the transformation takes place, not html is returned, any ideas why?

Thanks

Joe
 
Old January 9th, 2004, 04:21 AM
Friend of Wrox
 
Join Date: May 2003
Location: Delhi, Delhi, India.
Posts: 229
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Joe,

Just a little typo error in the following line:

Response.Write(sHrml)

Please correct the variable name as follows

Response.Write(sHtml)

Charul Shukla

 
Old January 9th, 2004, 08:50 AM
Registered User
 
Join Date: Jan 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, don't I feel like an idiot now, lol

Thanks Charul




Similar Threads
Thread Thread Starter Forum Replies Last Post
"Professional XML" book Habibb XML 1 November 7th, 2006 03:50 AM
Professional ASP.NET 2.0 Book SWA001 BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 1 May 30th, 2006 09:53 AM
Search code for book "Professional asp.net xml C#" Sunny@China All Other Wrox Books 1 December 4th, 2005 07:08 PM
Professional VB6 XML Book garnold@tfbbiking.com XML 2 December 15th, 2004 12:56 PM
code for book Professional ASP 3.0 ravinkumar Classic ASP Databases 0 September 18th, 2003 04:34 PM





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