Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Why this is not working.......

 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can anybody help me..The output is blank i.e names and phonenumbers are show..I suspect XSL is not traversing through tree.
-----------------------
1)addressbookXML.xml file
------------------------
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://localhost/testBud/xslfiles/addressbookXSL.xsl" type="text/xsl" ?>
<!DOCTYPE addressbook SYSTEM "http://localhost/testbud/xmlfiles/addressbookDTD.dtd">
<addressbook>
<address>
<name>Prasad Ballari</name>
<phone>3320328</phone>
</address>
<address>
<name> Sridhar MV</name>
<phone>4****</phone>
</address>
<address>
<name>Sendil C</name>
<phone>40****</phone>
</address>
<address>
<name>Bill Joe</name>
<phone>001-098-7489289</phone>
</address>
</addressbook>

--------------------
2)addressbookDTD.dtd
------------------
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT addressbook (address)+>
<!ELEMENT address (name,phone) >
<!ELEMENT name (#PCDATA)>
<!ELEMENT phone (#PCDATA)>

-----------------------
3) addressbookXSL.xsl
-----------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xml:template match="/">
<html>
<head><title>My address book</title> </head>
<body >
<h2> My Address Book on the Net2k</h2>
<xsl:for-each select = "addressbook/address">
<h5>hello<xsl:value-of select="name" /></h5>
</xsl:for-each>
<table align ="center" border="2">
<tr>
<th>Name</th>
<th>Phone Number</th>
</tr>
<xsl:for-each order-by="+ name " select ="addressbook/address">
<tr>
<td><xsl:value-of select="name" /></td>
<td><xsl:value-of select="phone" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xml:template>
</xsl:stylesheet>
Regards
Prasad

------------------
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi prasad,
this xsl will work
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" xmlns:fo="http://www.w3.org/TR/WD-xsl/FO" result-ns="fo">
<xsl:template match="/">
<html>
<head><title>My address book</title> </head>
<body >
<h2> My Address Book on the Net2k</h2>
<xsl:for-each select = "addressbook/address">
<h5>hello<xsl:value-of select="name" /></h5>
</xsl:for-each>
<table align ="center" border="2">
<tr>
<th>Name</th>
<th>Phone Number</th>
</tr>
<xsl:for-each order-by="+ name " select ="addressbook/address">
<tr>
<td><xsl:value-of select="name" /> </td>
<td><xsl:value-of select="phone" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
small change is that it is xsl:template and not xml:template
regards,
prabhu.
 
Maybe he went home and went to bed. And took this tiny ad with him:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic