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 July 17th, 2007, 11:13 AM
Registered User
 
Join Date: Jul 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT - 2 problems ...

Hello,

I have been following Michael Kay XSLT 2nd Edition Book and I am new to xslt and I have encountered 2 problems which I can not seem to find a solution to my problems i encountered.

1> It does not seem to display the property location extra details that corresponds to the property location.
2>tags such as prst_code which is for example would display garden but instead it displays in capitals as-“ GARD ” which I need to put to lowercase but then how do I get it to display the full word ‘garden’.

1> This is my xslt code -

<?xml version="1.0" encoding="iso-8859-1><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:param name="XLlocation"/>

<xsl:template match="/">
  <h2>Property Results:</h2>
    <xsl:for-each select="xxx_data/houses/property/address[contains(property_location,$XLlocation)]">
  <table width="70%" cellpadding="0" cellspacing="0" border="0" align="center">
    <tr>
      <td colspan="2" bgcolor="#CC6633" style="color:#FFFFFF" bordercolor="#000000" align="left"> <strong><xsl:value-of select="property_location"/></strong></td>
    <td bgcolor="#CC6633" style="color:#FFFFFF" bordercolor="#000000"><strong>
    <xsl:value-of select="//price_text"/></strong></td>
    </tr>
    <tr bgcolor="#E1DDE1">
      <td colspan="2"><img src="{//picture1}"/></td>
      <td valign="top" width="82%"><xsl:value-of select="//short_description"/></td>
    </tr>
    <tr bgcolor="#E1DDE1">
      <td colspan="2"><a href="{//slide_show}">Slide Show</a></td>
      <td height="30" valign="bottom" style="color:#000099">* <xsl:value-of select="//beds"/> Bedrooms * <xsl:value-of select="//baths"/> Bathrooms * <xsl:value-of select="//receptions"/> Receptions * <xsl:value-of select="//prag_code"/> * <xsl:value-of select="//prst_code"/> * <xsl:value-of select="//prty_code"/> * <xsl:value-of select="//prpa_code"/></td>
    </tr>
    <tr bgcolor="#E1DDE1">
    <td colspan="2"></td>
    <td height="30" valign="bottom" style="color:#000099"><a href="{//public_details_sheet}">Detail Sheet</a> | <a href="{//floorplan1}">Floor Plan</a></td>
    </tr>
  </table>
  <br /><br />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>


1> the first property details are correct – the short-description is correct and the number of beds, receptions, and the picture is all related to the first property location. BUT the second and the rest have the correct property location text e.g. Chiswick , hammersmith etc. but the picture, short description, number of beds, receptions etc are not of that property location but are the first property location details. I can not understand why that is happening. The only thing I can think but it should not be the case is the way we are getting the details through the child node ‘//’ ? But If I take them out then nothing appears – so maybe we will have to change something in the asp code page to be able to not display the //… what do you think?

2> the GARD is in capitals and short hand-written how can I change than to being lowercase and written out in the full word such as Garden

And Here is the asp code - passing the paramter...

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
dim strlocation
strlocation = Request.QueryString("lo")
%>
<% Response.ContentType = "text/html" %>
<%
Set xmldoc = Server.CreateObject("Msxml2.FreeThreadedDOMDocumen t.3.0")
xmldoc.async = false
xmlDoc.setProperty "ServerHTTPRequest", true
xmldoc.load("http://xxx.net/xxx/xxx/xxx_search.xml?upw=1467581F8E6F42D1BF0207B0A16964D E")

Set xsldoc = Server.CreateObject("Msxml2.FreeThreadedDOMDocumen t.3.0")
xsldoc.async = false
xsldoc.load("d:\inetpub\wwwroot\xxx\properties.xsl ")

Set Node = xmldoc.selectSingleNode("xxx_data/houses/property/address")

Set template=Server.CreateObject("MSXML2.XSLTemplate")
template.stylesheet=xsldoc

Set processor=template.createProcessor
processor.input = xmldoc
if strlocation <> "" then
processor.addParameter "XLlocation", "" & strLocation & ""
end if
processor.transform()
Response.write (processor.output)'(xmldoc.transformNode(xsldoc))
%>

Any help would be really appreciated - especially with the first problem.

Cheers
 
Old July 17th, 2007, 12:38 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Unfortunately you've shown neither your source XML nor your desired output so I'm having to guess a little.

Using expressions such as //price_text within a for-each is almost always wrong. You want to select something, I suspect, that're relative to the current <address> element. I can't correct the expression for you without seeing the source, but I can tell you that it won't start with "/", which always selects from the root of the document. Perhaps you want .//price_text, perhaps something more specific such as a/b/c/price_text.

When <xsl:value-of> selects a set of nodes in XSLT 1.0, it displays the value of the first of these node. In XSLT 2.0 it displays all the nodes, space separated, which makes the mistake more obvious.

I'm afraid I've no idea from this description which part of your code is displaying GARD rather than garden.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT problems thisby XSLT 2 April 3rd, 2008 09:17 AM
XSLT rendering problems in IE7 for Vista tripecac XSLT 17 July 4th, 2007 10:07 AM
namespace problems in xslt stekker XSLT 2 June 16th, 2006 09:59 AM
translate() problems in XSLT 2.0 dsanders XSLT 3 February 23rd, 2006 11:14 AM
xslt variable problems lincsimp XSLT 2 August 17th, 2005 02:49 AM





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