Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML/XSL Problem

Status
Not open for further replies.

transparent

Programmer
Sep 15, 2001
333
GB
Hello all. I'm trying to parse an xml document with an xsl document using asp's xml parser. I'm not getting any results at present.

Can anybody see the error in the following xsl / xml combination?

The XML:

<directorates>

<directorate name=&quot;Surgery Directorate&quot;>
<department>Accident & Emergency</department>
<department>Adult Audiology</department>
<department>Appliance</department>
<department>Anaesthetics</department>
<department>Breast Care</department>
</directorate>

<directorate name=&quot;General & Elderly Directirate&quot;>
<department>General Medicine</department>
<department>Elderly Medicine</department>
<department>Endoscopy</department>
<department>Dermatology</department>
<department>Pathology</department>
<department>Diabetes</department>
</directorate>

</directorates>

The XSL:

<?xml version=&quot;1.0&quot;?>
<xsl:stylesheet xmlns:xsl=&quot;<xsl:template match=&quot;/&quot;>

<xsl:for-each select=&quot;directorates/directorate&quot;



<b><xsl:value-of select=&quot;directorate/@name&quot; /></b>
<b><xsl:value-of select=&quot;department&quot; /></b>


</xsl:for-each>

</xsl:template>
</xsl:stylesheet>


Cheers
 
At first glance:
Code:
<xsl:for-each select=&quot;directorates/directorate&quot;> <-- gt

Also be sure you have your headers declared correctly, the biggest problem I have run into is header working here but not there. What kind of ASP error are you getting or is it just a blnk page?
-Tarwn
------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
I'm getting just a blank page...cheers for your help by the way.

What header do you suggest?
 
Right I've updated the XSL (see below) however it deosn't seem to iterate throught the deaprtments. Any idea why (I have included the output).

Cheers again

<?xml version=&quot;1.0&quot;?>
<xsl:stylesheet xmlns:xsl=&quot;<xsl:template match=&quot;/&quot;>

<xsl:for-each select=&quot;directorates/directorate&quot;>



<b><xsl:value-of select=&quot;@name&quot; /></b><br/>

<xsl:for-each select=&quot;department&quot;>
<xsl:value-of select=&quot;department&quot; /> <br/>
</xsl:for-each>


</xsl:for-each>

</xsl:template>
</xsl:stylesheet>

This returns:

Surgery Directorate
Accident & Emergency
Accident & Emergency
Accident & Emergency
Accident & Emergency
Accident & Emergency
Accident & Emergency
Accident & Emergency
Accident & Emergency
Accident & Emergency
General & Elderly Directirate
General Medicine
General Medicine
General Medicine
General Medicine
General Medicine
General Medicine
Surgery Directorate
General Surgery
General Surgery
General Surgery
General Surgery
General Surgery
General Surgery
General Surgery
General & Elderly Directirate
Cardiology
Cardiology
Cardiology
Cardiology
Cardiology
Child Health Directorate
Paediatrics
Paediatrics
Paediatrics
Paediatrics
Paediatrics
Paediatrics
Paediatrics
Paediatrics
Obstetrics and Gynaecology Directorate
Gynaecology
Gynaecology
Gynaecology
Gynaecology
Gynaecology
Gynaecology
Nursing and Midwifery Directorate
Effective Practice Unit
Allied Health Professions Directorate
Dietetics
Dietetics
Dietetics
Dietetics
Dietetics
Personnel Directorate
Occupational Health
Occupational Health
Occupational Health
Occupational Health
Occupational Health
Finance Directorate
Planning and monitoring
Planning and monitoring
Planning and monitoring
Planning and monitoring
Planning and monitoring
Modernisation Directorate
Computer Services
Computer Services
Computer Services
Computer Services
Facilities Directorate
Estates
Estates
Estates
 
<xsl:for-each select=&quot;department&quot;>
<xsl:value-of select=&quot;.&quot; /> <br/>
</xsl:for-each>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top