473,809 Members | 2,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML/XSD/XSL Display Problem

Hi,

I'm trying to put my resume on my website, and I want to do it using
XML and XSL. If I don't include the schema in the mix, the xml
displays without a problem. When I add the schema location to the xml,
however, it doesn't seem to be displaying the html tags. It just puts
all the information on the screen in one big block, almost like it's
reading the xml information, but not the html I have in my XSL. I know
all the XML/XSL/XSD stuff is well-formed because I have an editor
(XMLSpy) to yell at me for that kind of stuff. Here's what I have so
far:

---BEGIN XML---

---XML---
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="resume.xs l"?>
<resume xmlns='http://www.nickshaw.ne t'
xmlns:xsi='http ://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocat ion='http://www.nickshaw.ne t resume.xsd'>
<contact-info>
<name>Nichola s J. Shaw</name>
<address location="Home" >
...

---XSL---
<xsl:styleshe et version="1.0" xmlns="http://www.nickshaw.ne t"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:template match="/resume">
<html>
<head>
<title>Resume </title>
<link rel="stylesheet " type="text/css" media="screen"
href="resume.cs s" />
</head>
<body>
<h1>
<xsl:value-of select="contact-info/name"/>
</h1>

<xsl:for-each select="contact-info/phone-number">
<xsl:value-of select="@locati on" />: <xsl:value-of
select="/resume/contact-info/phone-number" /><br/>
</xsl:for-each>

E-Mail: <xsl:value-of select="contact-info/e-mail" /><br/>

<xsl:for-each select="contact-info/address">
<p>
<h3><xsl:valu e-of select="@locati on" /></h3>
<xsl:value-of select="street-1"/>
<xsl:if test="street-2">, <xsl:value-of
select="street-2"/><br /></xsl:if>
<xsl:if test="not(stree t-2)"><br /></xsl:if>
<xsl:value-of select="city"/>, <xsl:value-of
select="state"/><br />
<xsl:value-of select="zip"/>
</p>
</xsl:for-each>

<h3>Objective </h3>
<p><xsl:value-of select="objecti ve" /></p>

<h3>Skills</h3>
<xsl:for-each select="skill-set/skill-group">
<h4><xsl:valu e-of select="@name" /></h4>
<ul>
<xsl:for-each select="skill">
<li><xsl:valu e-of select="." /></li>
</xsl:for-each>
</ul>
</xsl:for-each>

<h3>Education </h3>
<xsl:for-each select="educati on">
<xsl:value-of select="univers ity" /><br />
<xsl:value-of select="start-date" /> through <xsl:value-of
select="end-date" /><br />
<xsl:if test="expected-graduation">
<xsl:value-of select="expecte d-graduation" /><br />
</xsl:if>
<ul>
<xsl:for-each select="degree" >
<li><xsl:valu e-of select="@type" /> in <xsl:value-of
select="." /></li>
</xsl:for-each>
</ul>
<ul>
<xsl:for-each select="gpa">
<li><xsl:valu e-of select="@type" />: <xsl:value-of
select="." /></li>
</xsl:for-each>
</ul>
</xsl:for-each>

<h3>Coursewor k</h3>
<xsl:for-each select="coursew ork/class-group" >
<xsl:value-of select="@name" /><br />
<ul>
<xsl:for-each select="class">
<li><xsl:valu e-of select="." /></li>
</xsl:for-each>
</ul>
</xsl:for-each>

<h3>Work Experience</h3>
<xsl:for-each select="work-experience/job">
<xsl:value-of select="company " /> - <xsl:value-of
select="locatio n" /><br />
<xsl:value-of select="job-title" /> - <xsl:value-of
select="start-date" /> through <xsl:value-of select="end-date" /><br />
<ul>
<xsl:for-each select="respons ibility">
<li><xsl:valu e-of select="." /></li>
</xsl:for-each>
</ul>
</xsl:for-each>

<h3>Reference s</h3>
<ul>
<xsl:for-each select="referen ces/reference">
<li><xsl:valu e-of select="." /></li>
</xsl:for-each>
</ul>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

---XSD---
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.nickshaw.ne t"
targetNamespace ="http://www.nickshaw.ne t"
elementFormDefa ult="qualified" >
<xs:element name="resume">
<xs:complexType >
<xs:all>
<xs:element name="contact-info">
...

---END XML--

I think this is a problem with namespaces (or I could be completely
wrong). I am pretty new to all this (As of about 2 days ago). Any help
anyone could provide will be greatly appreciated. If you need any more
information, just ask. Thanks!

Nick Shaw

Jul 20 '05 #1
5 1597


Nick Shaw wrote:

<resume xmlns='http://www.nickshaw.ne t'
You have a default namespace here meaning your <resume> element and its
child elements are in the namespace with the URI http://www.nickshaw.net.

<xsl:styleshe et version="1.0" xmlns="http://www.nickshaw.ne t"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:template match="/resume">
<html>


You again set the default namespace meaning now that <html> element is
in the namespace with the URI http://www.nickshaw.net while you probably
want to create HTML output where the <html> element should be in no
namespace. So you likely want
<xsl:styleshe et
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:ns="http://www.nickshaw.ne t"
version="1.0">
<xsl:template match="ns:resum e">
<html>
Of course as your input elements are in a namespace you need to make
sure all your XPath expressions and match patterns have the proper
prefix e.g. stuff like
<xsl:for-each select="contact-info/address">
needs to be
<xsl:for-each select="ns:cont act-info/ns:address">

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
Worked perfect! So just to make sure I understand this, the HTML was
being output to another namespace instead of to no namespace which was
making it unable to render the HTML in the browser? I thought I had it
all in no namespace (the XML and the XSL, anyway) and it was working
fine, but when I added in the schema, it caused problems because it was
in a namespace? Is it possible to have the schema and not have to
prefix every XPath expression with some namespace qualifier? Sorry if
these are very naive questions, but I'm having a little trouble with
this concept of namespaces. Thanks!

Nick Shaw

Jul 20 '05 #3

Nick Shaw wrote:
Is it possible to have the schema and not have to
prefix every XPath expression with some namespace qualifier?


It is possible to write a schema for elements in no namespace, don't use
the targetNamespace then and use elementFormDefa ult="unqualifie d".

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #4
Ok, that makes sense. One last question: As far as best practice, it
is probably best to specify a namespace rather than to use the default
namespace to qualify elements to prevent collisions, correct?

Jul 20 '05 #5


Nick Shaw wrote:
One last question: As far as best practice, it
is probably best to specify a namespace rather than to use the default
namespace to qualify elements to prevent collisions, correct?


To prevent collisions it is best practice to define your elements in a
namespace when you set up a schema.
Whether you make use of a default namespace or not is another and
unrelated question, a default namespace is only a tool to shorten your
XML once you have decided to use a namespace.
In the XML document

<root>
<text>Kibolog y for all.</text>
</root>

all elements are in no namespace and if someone uses that XML with XML
from different sources it will not be possible to distinguish for
instance the <root> element above from a <root> element elsewhere which
was meant to have a different semantics.
That is why people put their elements in a namespace but it is then
simply more convenient to write the XML as e.g.

<root xmlns="http://example.com/2005/07/ex1">
<text>Kibolog y for all.</text>
</root>

than to write

<pf:root xmlns:pf="http://example.com/2005/07/ex1">
<pf:text>Kibolo gy for all.</text>
</pf:root>

both ways the elements are now in the namespace with the URI
http://example.com/2005/07/ex1.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #6

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

Similar topics

1
3600
by: Agency | last post by:
I'm still working on the bpm counter. I need to have at least 2 displays that are not static. One would be a clock/running time and the other would should the current beat count. How would I do this in Tkinter? I was thinkning of canvas-text, but there must be a widget for doing this kind of display. I'm a bit lost and would appreciate some help.
5
1916
by: David Greenwood | last post by:
I posted this under 'microsoft.public.sqlserver.client' but got no reply. Any help with this problem would be greatly appreciated --------------------- I developed a database under SQL Server 2000, with Access 2000 on Windows 2000 as client. This had been running fine for several years. The client is now upgrading to Windows XP, and has come across a display problem on the reports. The figures are correct but are now displayed with lots of...
13
40778
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div style="display:none"> can be displayed by setting the style attribute to "display:", or hidden with "display:none". This gives the illusion that the person filling out the form is switching from page to page...without the overhead of extra hits on the server,...
19
6937
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the JavaScript in this code from a couple different sites but I'm not 100% sure what each line is doing...This is the ASP code that I'm using for the page....Take a look at the JavaScript code and please let me know what each line is doing....I have been...
3
10259
by: shreddie | last post by:
Could anyone assist with the following problem? I'm using JavaScript to hide/show table rows depending on the option selected in radio buttons. The script works fine in IE but in Firefox the hidden rows take up page space even though their content is not visible. I have extracted the necessary code as shown below: ************************************************************************
2
1991
by: s.chelliah | last post by:
We have an input field which allows the user to enter a string of (up to 62) ASCII printable characters. We have a need to allow the user to be able to specify any sequence of characters he/she desires. However, we have a problem when we attempt to display this same string of characters. If the input sequence of characters contains HTML interpretable strings of characters, the user's sequence of characters is not properly displayed. (We...
2
3367
by: ruby_bestcoder | last post by:
Hi Im having problem in firefox with display:none/block. I have essentially 3 li elements. In each element there are a few nested div:s. Clicking on one of the divs, makes another div to display: block or none. Again this works in IE. In ff it has a bug. When the display is none for a div in the first li, then the next li (the one underneath) moves up to the right, looking very ugly. Is there someone who has had the
7
3080
by: Janis | last post by:
I try to understand what could be the source of a problem with displaying and hiding rows of tables using display:block/none. I've read selfhtml but could not find any hint about that. Any pointers why that can happen, or how I should take care of that type of problem/effect are highly appreciated. The problem... A couple times the hiding/displaying works, but _occasionally_ the entries are hidden but _blank lines appear_, instead.
15
3171
by: cssExp | last post by:
hello, Rather than going on a wild explanation on what's the the problem, it'll be much quicker and easier if i let you look at it yourself, so I'll post my page source (actual contents taken out, of course). <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Language" content="en-us" />
10
7424
by: dkyadav80 | last post by:
<html> /// here what shoud be java script for: ->when script run then not display all input text field only display selection field. ->when user select other value for institute only this field display not display degree text field ->when user select other value in the selection field for degree then text field display and wise versa //// <bodly> <table>
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10383
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6881
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.