473,412 Members | 3,471 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

No results from XML to HTML via XSLT?

Any ideas why I am not getting any results back in my HTML via XSLT
from my XML doc. It is not returning any errors just no matches when
it should return a value of DATA for SchemeName ??
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" />
<xsl:template match="/">
<html>
<head>
<title>Building Control</title>
</head>
<body>
<h3>Building Control</h3>
<table border="0" width="80%" cellpadding="2" cellspacing=
"1" bgcolor="#999999">
<tr bgcolor="#dedede">
<th>Scheme</th>
</tr>
<xsl:for-each select="SchemeName">
<tr bgcolor="#ffffff">
<td><xsl:value-of select="SchemeName" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

----------------------------------------

This is my XML Schema

<?xml version="1.0" encoding="UTF-16" ?>
- <BuildingRecordSet xmlns:rs="urn:schemas-microsoft-com:rowset"
xmlns:z="#RowsetSchema"
xmlns:apd="http://www.govtalk.gov.uk/people/AddressAndPersonalDetails">
<SchemeName>DATA</SchemeName>
<LocalAuthorityCode>DATA</LocalAuthorityCode>
- <BuildingRecord>
<SchemeUniqueRecordIdentifier>2</SchemeUniqueRecordIdentifier>
<CompetentPerson>
<PersonRegistrationNumber>02</PersonRegistrationNumber>
<InstallerRegisteredName>Name</InstallerRegisteredName>
</CompetentPerson>
<WorkPerformed>
<PropertyInformation>
<PropertyLocation>
<PropertyAddress>
<apd:A_5LineAddress>
<apd:Line>Bank</apd:Line>
<apd:Line />
<apd:Line />
<apd:Line></apd:Line>
<apd:PostCode></apd:PostCode>
</apd:A_5LineAddress>
</PropertyAddress>
</PropertyLocation>
</PropertyInformation>
<DateWorkCompleted>20/01/2005</DateWorkCompleted>
<DescriptionOfWorkItem>Shower</DescriptionOfWorkItem>
</WorkPerformed>
</BuildingRecord>
</buildingrecordset>
Jul 20 '05 #1
4 1439

<xsl:template match="/">

so here the current node is / representing the whole document.

<xsl:for-each select="SchemeName">

this selects SchemeName children of the docuemnt node, there are none,
tehre can only be one element node child of / in a well formed document
and in this case that's BuildingRecordSet
probably you just want to change your
match="/"
to
match="BuildingRecordSet"

(the default template for / will apply templates to its children)

If you do that then

<xsl:for-each select="SchemeName">

would select all the SchemeName children but then
<td><xsl:value-of select="SchemeName" /></td>

would generate an empty td as there are no SchemeName children of the
current node at that point (which is SchemeName)

If you only have one SchemeName element get rid of the for-each and do

<td><xsl:value-of select="SchemeName" /></td>

or if you have more than one and you want a td for each of them do

<xsl:for-each select="SchemeName">
<tr bgcolor="#ffffff">
<td><xsl:value-of select="." /></td>

David
Jul 20 '05 #2
David

By replacing the / with BuildingRecordSet
has returned the data.

I have added the following table to retrieve more data from the XML Doc
but again it is returning no results just empty table cells ??

<table border="0" width="80%" cellpadding="2" cellspacing="1"
bgcolor="#999999">
<tr bgcolor="#dedede">
<th colspan="2">Building Record</th>
</tr>

<tr bgcolor="#ffffff">
<xsl:for-each select="SchemeUniqueRecordIdentifier">
<td>
<xsl:value-of select="SchemeUniqueRecordIdentifier" />
</td>
</xsl:for-each>

<xsl:for-each select="PersonRegistrationNumber"">
<td>
<xsl:value-of select="PersonRegistrationNumber" />
</td>
</xsl:for-each>
</tr>
</table>
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3


same mistake as before:

<xsl:for-each select="SchemeUniqueRecordIdentifier">
so here current node is SchemeUniqueRecordIdentifier
<td>
<xsl:value-of select="SchemeUniqueRecordIdentifier" />
this is looking for a SchemeUniqueRecordIdentifier child of the
current node, when actually you want the current node not its
child. this will only be non-empty of you have
<SchemeUniqueRecordIdentifier>
<SchemeUniqueRecordIdentifier>
...
</SchemeUniqueRecordIdentifier>
</SchemeUniqueRecordIdentifier>
</td>
so you want either
<xsl:for-each select="SchemeUniqueRecordIdentifier">
<td>
<xsl:value-of select="." />
</td>
</xsl:for-each>

or if you only have one such element,

<td>
<xsl:value-of select="SchemeUniqueRecordIdentifier" />
</td>
and this is same again:-):

<xsl:for-each select="PersonRegistrationNumber"">
<td>
<xsl:value-of select="PersonRegistrationNumber" />
</td>
</xsl:for-each>

David
Jul 20 '05 #4
Do you have any examples I can follow of converting the XML doc into a
fixed width CSV file ?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: inetquestion | last post by:
Can someone point me in the right direction regarding xml/xslt? I have the following xml file with corresponding xslt and would like to add some aditional functionality where a viewer can select...
6
by: Lenny Wintfeld | last post by:
Hi I'm attempting additions/changes to a Java program that (among other things) uses XSLT to transform a large (96 Mb) XML file. It runs fine on small XML files but generates OutOfMemory...
2
by: Mad Scientist Jr | last post by:
>From an asp.net web page I want the user to open the results of a SQL query in Excel, as automatically as possible (ie not having to loop through columns, rows, in code). For this,...
1
by: Ken Fine | last post by:
I have set up Microsoft Search Server 2008 Express. I want to know how I can query against it and return results in a form that can be bound to ASP.NET controls like ListViews. If there's simply...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.