473,320 Members | 1,946 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,320 software developers and data experts.

xsl problem with xsd

107 100+
hi guys, i have the following xml file:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <?xml-stylesheet href="election.xsl" type="text/xsl" ?>
  3. <?xml-stylesheet type="text/xsl" href="election.xsl"?>
  4. <election>
  5.     <poll>
  6.         <province>Province 1</province>
  7.         <district>District 1</district>
  8.         <division>Division 1</division>
  9.         <year>2013</year>
  10.         <registered_voters>2000</registered_voters>
  11.         <vote_rejected>50</vote_rejected>
  12.         <vote_received>
  13.             <party>
  14.                 <partyname>Party 1</partyname>
  15.                 <symbol>Symbol 1</symbol>
  16.                 <color>Red</color>
  17.                 <candidate_name>Mr. X</candidate_name>
  18.                 <no_votes>1750</no_votes>
  19.             </party>
  20.             <party>
  21.                 <partyname>Party 2</partyname>
  22.                 <symbol>Symbol 2</symbol>
  23.                 <color>Green</color>
  24.                 <candidate_name>Mr. Y</candidate_name>
  25.                 <no_votes>200</no_votes>
  26.             </party>
  27.         </vote_received>
  28.     </poll>
  29.     <poll>
  30.         <province>Province 2</province>
  31.         <district>District 1</district>
  32.         <division>Division 3</division>
  33.         <year>2013</year>
  34.         <registered_voters>1000</registered_voters>
  35.         <vote_rejected>20</vote_rejected>
  36.         <vote_received>
  37.             <party>
  38.                 <partyname>Party 1</partyname>
  39.                 <symbol>Symbol 3</symbol>
  40.                 <color>Blue</color>
  41.                 <candidate_name>Mr. Z</candidate_name>
  42.                 <no_votes>860</no_votes>
  43.             </party>
  44.             <party>
  45.                 <partyname>Party 2</partyname>
  46.                 <symbol>Symbol 4</symbol>
  47.                 <color>Black</color>
  48.                 <candidate_name>Mr. A</candidate_name>
  49.                 <no_votes>120</no_votes>
  50.             </party>
  51.         </vote_received>
  52.     </poll>
  53. </election>
  54.  
And my xsl as follows:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Edited by XMLSpy® -->
  3. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  4.  
  5.  
  6. <xsl:template match="/">
  7.     <html>
  8.         <body>
  9.             <xsl:for-each select="election/poll">
  10.             <xsl:sort select="." order="ascending"/>
  11.                 <table border="1">
  12.                     <tr>
  13.                         <td>
  14.                             <table>
  15.                                 <tr>
  16.                                     <td><xsl:value-of select="province"/></td>
  17.                                 </tr>
  18.                                 <tr>
  19.                                     <td><xsl:value-of select="district"/></td>
  20.                                 </tr>
  21.                                 <tr>
  22.                                     <td><xsl:value-of select="division"/></td>
  23.                                 </tr>
  24.                                 <tr>
  25.                                     <td><xsl:value-of select="year"/></td>
  26.                                 </tr>
  27.                             </table>
  28.                         </td>
  29.                         <td>
  30.                             <table>
  31.                                 <tr bgcolor="#9acd32">
  32.                                     <td>Registered Voters: <xsl:value-of select="registered_voters"/></td>
  33.                                     <td>Votes Rejected: <xsl:value-of select="vote_rejected"/></td>
  34.                                 </tr>
  35.                                 <xsl:for-each select="vote_received/party">
  36.                                 <tr>
  37.                                     <td colspan="2">
  38.                                         <table border="1">
  39.                                             <tr bgcolor="#9acd32">
  40.                                                 <td>Party Name: <xsl:value-of select="partyname"/></td>
  41.                                             </tr>
  42.                                             <tr>
  43.                                                 <td>Symbol: <xsl:value-of select="symbol"/></td>
  44.                                             </tr>
  45.                                             <tr>
  46.                                                 <td>Color: <xsl:value-of select="color"/></td>
  47.                                             </tr>
  48.                                             <tr>
  49.                                                 <td>Candidate Name: <xsl:value-of select="candidate_name"/></td>
  50.                                             </tr>
  51.                                             <tr>
  52.                                                 <td>Number of Votes: <xsl:value-of select="no_votes"/></td>
  53.                                             </tr>
  54.                                         </table>
  55.                                     </td>
  56.                                 </tr>
  57.                                 </xsl:for-each>
  58.                                 <tr bgcolor="#9acd32">
  59.                                     <td>Total Votes Received: <xsl:value-of select="sum(vote_received/party//no_votes)"/></td>
  60.                                 </tr>
  61.                             </table>
  62.                         </td>
  63.                     </tr>
  64.                 </table>
  65.             </xsl:for-each>
  66.         </body>
  67.     </html>
  68. </xsl:template></xsl:stylesheet>
  69.  
The xsl works fine for now but if i add the following schema link to validate my xml then nothing displays:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <?xml-stylesheet href="election.xsl" type="text/xsl" ?>
  3. <?xml-stylesheet type="text/xsl" href="election.xsl"?>
  4. <election xmlns="http://www.w3schools.com"
  5. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  6. xsi:schemaLocation="http://www.w3schools.com election.xsd">
  7.     <poll>
  8.         <province>Province 1</province>
  9.         <district>District 1</district>
  10.         <division>Division 1</division>
  11.         <year>2013</year>
  12. ..........
  13.  
What could be the reason, please enlighten me!
Dec 27 '13 #1
1 1177
Dormilich
8,658 Expert Mod 8TB
you’ve given all your XML elements a new Namespace, hence the XPaths in the XSL do not match the XML any more.
Dec 27 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Aldo Polli | last post by:
Hi, I have this error when I start apache2 with php4 Syntax error on line 233 of /mypath/apache2/conf/httpd.conf: Cannot load /mypath/apache2/modules/libphp4.so into server: dynamic linker:...
0
by: Madhusudan Singh | last post by:
Hi After months of waiting for Redhat to come out with up to date rpms, I decided to compile a working OpenSSL/ MySQL / PHP / httpd installation for myself. Installed the latest versions of...
0
by: Alexander Skwar | last post by:
Hello! I'm having problems getting PHP 4.3.3RC4 successfully to install on my HP-UX 11.00 server. After a (successfull?) compile, "make install" errors out with this error message: ...
3
by: Mike Henley | last post by:
I first came across rebol a while ago; it seemed interesting but then i was put off by its proprietary nature, although the core of the language is a free download. Recently however, i can't...
7
by: Darren Gamble | last post by:
Good day, I've sent a message on this to the php-general list already, but unfortunately no one replied. Sorry for the repost. to those that read both... I'm having a problem working with an...
7
by: kecebong | last post by:
I tried to compile php 4.3.3 with gd but it doesn't work, it wasnt show in phpinfo(). My system is redhat 9 and apache 2.0.47 webserver.
4
by: Hugh Cowan | last post by:
Hello, I don't program full-time (anymore), but I do try and stay on-top of the latest technologies and like most are always trying to upgrade my skills and remain current (as much as is...
3
by: Mike | last post by:
Hi, I have an architectural type question that centers around php. We have a website that people hit that uses php to dynamically generate web pages. We use Apache and php (although we don't have...
0
by: Slavik | last post by:
All libraries were installed (precompiled) This is FreeBSD 5.1 installed zlib, installed jpeg and png libraries (in default directories) GD 2.0.11 source is in /usr/gd-2.0.11 (compiled and...
4
by: MegaZone | last post by:
I'm having some issues with PHP DOMXML - in particular the get_elements_by_tagname method. Now, the PGP docs on this are, well, sparse, so maybe I'm just doing something stupid. I thought this...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.