3 Replies - 1144 Views - Last Post: 17 November 2011 - 01:41 PM

#1 eZACKe   User is offline

  • Garbage Collector

Reputation: 120
  • View blog
  • Posts: 1,278
  • Joined: 01-June 09

XML Problem

Posted 12 November 2011 - 02:34 PM

Firstly, I honestly have no idea where on this site to post this question. I did a search at the top of the site for "xml" and most of the results were PHP topics so I'm positing this here. If a mod wants to move it, that's fine.

My problem is: I'm working with XML for the first time and when I run my XML file on the browser nothing is being shown at all.

I have a DTD file, the XML file itself, and a XSL file.

DTD (photoOrders.dtd):
<!-- photoOrders.dtd -->
<!-- DTD document for photoOrders.xml -->

<!ELEMENT photoOrders (retailOutlet, submissionDate, submissionTime, orders*)>
				   
<!ELEMENT retailOutlet (name, retailAddress, city, state, 
                     zip, phone)>

<!ELEMENT retaillAddress (number, street)>
					 
<!ELEMENT orders (customerName, customerAddress?, phone, email?, 
					customerOrders+)>

<!ELEMENT customerName (firstName?, lastName)>

<!ELEMENT customerAddress (number, street, city, state, 
					zip)>

<!ELEMENT customerOrders (medium, copies, size, finishing, 
					urgency)>
					
	
<!ELEMENT submissionDate (#PCDATA)>	
<!ELEMENT submissionTime (#PCDATA)>	
<!ELEMENT name (#PCDATA)>
<!ELEMENT number (#PCDATA)>
<!ELEMENT street (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT state (#PCDATA)>
<!ELEMENT zip (#PCDATA)>
<!ELEMENT phone (#PCDATA)>
<!ELEMENT firstName (#PCDATA)>
<!ELEMENT lastName (#PCDATA)>
<!ELEMENT email (#PCDATA)>
<!ELEMENT medium (#PCDATA)>
<!ELEMENT size (#PCDATA)>
<!ELEMENT copies EMPTY>
<!ELEMENT finishing EMPTY>
<!ELEMENT urgency EMPTY>

<!-- Enumerated type values, with default indicated -->
<!ATTLIST copies number (1 | 2 | 3 | 4) "1">
<!ATTLIST finishing type (matte | glossy | black-and-white) "matte">
<!ATTLIST urgency type (normal | urgent) "normal">



XML (photoOrders1.xml):
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="photoOrders.xsl"?>

<!DOCTYPE photoOrders SYSTEM "photoOrders.dtd">

<photoOrders>
	<retailOutlet>
		<name>Rite Aid #1337</name>
			 
		<retailAddress>
			<number>350</number>
			<street>Sheely St</street>
		</retailAddress>

		<city>Elmira</city>
		<state>NY</state>
		<zip>14904</zip>
		<phone>607-884-2146</phone>
	</retailOutlet>
	
	<submissionDate>11/12/2011</submissionDate>
	<submissionTime>9:30</submissionTime>
	
	<orders>
		<customerName>
			<firstName>Zachary</firstName>
			<lastName>Hine</lastName>
		</customerName>
		
		<customerAddress>
			<number>931</number>
			<street>Link St</street>
			<city>Elmira</city>
			<state>NY</state>
			<zip>14904</zip>
		</customerAddress>
		
		<phone>607-733-9167</phone>
		<email>[email protected]</email>
		
		<customerOrders>
			<medium>Flash Drive</medium>
			<copies number = "3" />
			<size>4x6</size>
			<finishing type = "matte" />
			<urgency tye = "normal" />
		</customerOrders>
		
		<customerOrders>
			<medium>CD</medium>
			<copies number = "2" />
			<size>8x11</size>
			<finishing type = "black-and-white" />
			<urgency tye = "urgent" />
		</customerOrders>
	</orders>
	
	<orders>
		<customerName>
			<firstName>John</firstName>
			<lastName>Kennedy</lastName>
		</customerName>
		
		<customerAddress>
			<number>1600 </number>
			<street>Pennsylvania Ave NW</street>
			<city>Washington</city>
			<state>DC</state>
			<zip>20500</zip>
		</customerAddress>
		
		<phone>888-888-0008</phone>
		<email>[email protected]</email>
		
		<customerOrders>
			<medium>Memory Card</medium>
			<copies number = "3" />
			<size>4x6</size>
			<finishing type = "glossy" />
			<urgency tye = "normal" />
		</customerOrders>
	</orders>
</photoOrders>



XSL (photoOrders.xsl):
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/TR/WD-xsl">

<!-- photoOrders.xsl -->
<!-- Way of transforming the photo orders into HTML -->

<xsl:template match = "/">

 <html>
 <head>
	<link rel="stylesheet" type="text/css" href="photoOrders.css" />
	<title>Photo Orders</title>
 </head>

 <body>
 
 <!-- First display the retailer details -->
	<div id="retailSection">
		<p><xsl:value-of select = "name"/></p>
		<p><xsl:value-of select = "photoOrders/retailOutlet/retailAddress/number"/> <xsl:value-of select = "photoOrders/retailOutlet/retailAddress/street"/></p>
		<p><xsl:value-of select = "photoOrders/retailOutlet/city"/>, <xsl:value-of select = "retailOutlet/state"/> <xsl:value-of select = "retailOutlet/zip"/></p>
		<p><xsl:value-of select = "photoOrders/retailOutlet/phone"/></p>
		<p><xsl:value-of select = "submissionDate"/>/<xsl:value-of select = "submissionTime"/></p>
	</div>
	
	<xsl:for-each select = "photoOrders/orders">
		<label>Customer name: </label>
		<p><xsl:value-of select = "customerName/firstName"/> <xsl:value-of select = "customerName/lastName"/></p>
		<p><xsl:value-of select = "customerAddress/number"/> <xsl:value-of select = "customerAddress/street"/></p>
		<p><xsl:value-of select = "customerAddress/city"/>, <xsl:value-of select = "customerAddress/state"/> <xsl:value-of select = "customerAddress/zip"/></p>
		<p><xsl:value-of select = "phone"/></p>
		<p><xsl:value-of select = "email"/></p>
		
		<label>Orders: </label>
		<table class="customerTable">
			<tr>
				<th width='200'>Photo Medium</th>
				<th width='50'>Copies</th>
				<th width='100'>Size</th>
				<th width='200'>Finishing</th>
				<th width='100'>Urgency</th>
			</tr>
			<xsl:for-each select = "customerOrders">
				<tr>
					<td width='200'><xsl:value-of select = "medium"/></td>
					<td width='50'><xsl:value-of select = "copies"/></td>
					<td width='100'><xsl:value-of select = "size"/></td>
					<td width='200'><xsl:value-of select = "finishing"/></td>
					<td width='100'><xsl:value-of select = "urgency"/></td>
				</tr>
			</xsl:for-each>
		</table>
	</xsl:for-each>
	</body>
	</html>
</xsl:stylesheet>



I have run the XML file through a validator and it gives no errors.

Again, sorry that this is probably posted in the wrong place.

Thanks for the help though!

Is This A Good Question/Topic? 0
  • +

Replies To: XML Problem

#2 e_i_pi   User is offline

  • = -1
  • member icon

Reputation: 879
  • View blog
  • Posts: 1,893
  • Joined: 30-January 09

Re: XML Problem

Posted 12 November 2011 - 02:42 PM

In your XML file, all of your orders have the urgency node written like this:
<urgency tye = "normal" />


Shoudn't "tye" read "type"? Not sure if that will solve your problem, but it's something that should be fixed up anyhow.
Was This Post Helpful? 3
  • +
  • -

#3 eZACKe   User is offline

  • Garbage Collector

Reputation: 120
  • View blog
  • Posts: 1,278
  • Joined: 01-June 09

Re: XML Problem

Posted 12 November 2011 - 03:48 PM

Yep, that was one error, among others.

I have it fixed now though. Thanks!
Was This Post Helpful? 0
  • +
  • -

#4 IT student-Oman   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 17-November 11

Re: XML Problem

Posted 17 November 2011 - 01:41 PM

i read your codes but i couldnt find the solution for ur problem but i can give u on advice
use dtd as inline file it will be easy for u and may get the result that u want
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1