473,406 Members | 2,293 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,406 software developers and data experts.

<xsl:apply-templates> effect on DOM object type?

I am using Firefox 2.0.0.3 on MSWindows.
I have an XML file http://emle.sourceforge.net/emle020000/testb.xml
which invokes an XSLT file http://emle.sourceforge.net/emle020000/testb.xsl

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="testb.xsl" type="text/xsl"?>
<z xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<x/>
</z>
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output
method="xml"
encoding="iso-8859-1"
indent="yes"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
/>

<xsl:template match="/z">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
.... DEBUG CODE DELETED. ...
</head>
<body onload="init();">
<div>
<xsl:apply-templates select="x" />
</div>
</body>
</html>
</xsl:template>

<xsl:template match="x">
<span>
<svg xmlns="http://www.w3.org/2000/svg" />
</span>
</xsl:template>

</xsl:stylesheet>
The result of the transform is:
<!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
xmlns="http://www.w3.org/1999/xhtml"><script type="text/javascript">
function init() { lu = function luf(){return
'http://www.w3.org/1999/xhtml';}; var span = document.evaluate("//span",
document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null)
..singleNodeValue; var div = document.evaluate("//xhtml:div", document,
lu, XPathResult.FIRST_ORDERED_NODE_TYPE, null) .singleNodeValue;
alert("span:" + span + " div:" + div); return; } </script></head><body
xmlns="http://www.w3.org/1999/xhtml" onload="init();"<div <span <svg
xmlns="http://www.w3.org/2000/svg"/ </span</div></body></html>The alert
displays span as an Element object and the div as an HTMLDivElement.
What is it about the <xsl:template match="x"that has this effect?

--
C.W.Holeman II | cw***@Julian5Locals.com -5 | http://JulianLocals.com/cwhii
To only a fraction of the human race does God give the privilege of
earning one's bread doing what one would have gladly pursued free, for
passion. I am very thankful. The Mythical Man-Month Epilogue/F.P.Brooks
Apr 12 '07 #1
4 2089
Wrapped lines fixed.

I am using Firefox 2.0.0.3 on MSWindows.
I have an XML file http://emle.sourceforge.net/emle020000/testb.xml
which invokes an XSLT file http://emle.sourceforge.net/emle020000/testb.xsl

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="testb.xsl" type="text/xsl"?>
<z xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<x/>
</z>
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output
method="xml"
encoding="iso-8859-1"
indent="yes"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
/>

<xsl:template match="/z">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
.... DEBUG CODE DELETED. ...
</head>
<body onload="init();">
<div>
<xsl:apply-templates select="x" />
</div>
</body>
</html>
</xsl:template>

<xsl:template match="x">
<span>
<svg xmlns="http://www.w3.org/2000/svg" />
</span>
</xsl:template>

</xsl:stylesheet>
The result of the transform is:

<!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 xmlns="http://www.w3.org/1999/xhtml">
<script type="text/javascript">
function init() {
lu = function luf(){return 'http://www.w3.org/1999/xhtml';};
var span = document.evaluate("//span",
document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null)
.singleNodeValue;
var div = document.evaluate("//xhtml:div",
document, lu, XPathResult.FIRST_ORDERED_NODE_TYPE, null)
.singleNodeValue;
alert("span:" + span + " div:" + div);
return;
}
</script>
</head>
<body xmlns="http://www.w3.org/1999/xhtml" onload="init();">
<div>
<span>
<svg xmlns="http://www.w3.org/2000/svg"/>
</span>
</div>
</body>
</html>

The alert displays span as an Element object and the div as an
HTMLDivElement.
What is it about the <xsl:template match="x"that has this effect?

--
C.W.Holeman II | cw***@Julian5Locals.com -5 | http://JulianLocals.com/cwhii
To only a fraction of the human race does God give the privilege of
earning one's bread doing what one would have gladly pursued free, for
passion. I am very thankful. The Mythical Man-Month Epilogue/F.P.Brooks
Apr 12 '07 #2
XSLT is namespace-aware. Your stylesheet copies a <spanelement with no
namespace into the output document, which means it won't be recognized
as being an XHTML span element.

Change your code to:

<xsl:template match="x">
<span xmlns="http://www.w3.org/1999/xhtml">
<svg xmlns="http://www.w3.org/2000/svg" />
</span>
</xsl:template>

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Apr 12 '07 #3
C.W.Holeman II wrote:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
Add
xmlns="http://www.w3.org/1999/xhtml"
to the xsl:stylesheet element, that way all your literal XHTML elements
will be in the XHTML namespace. Otherwise in any template you write you
will need to make sure that the XHTML default namespace declaration is
set for XHTML elements.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Apr 12 '07 #4
"Joseph Kesselman" <ke************@comcast.netwrote in message
news:461e4471@kcnews01...
XSLT is namespace-aware. Your stylesheet copies a <spanelement with no
namespace into the output document, which means it won't be recognized as
being an XHTML span element.

Change your code to:

<xsl:template match="x">
<span xmlns="http://www.w3.org/1999/xhtml">
<svg xmlns="http://www.w3.org/2000/svg" />
</span>
</xsl:template>
"Martin Honnen" <ma*******@yahoo.dewrote in message
news:46***********************@newsspool4.arcor-online.net...
C.W.Holeman II wrote:
><xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

Add
xmlns="http://www.w3.org/1999/xhtml"
to the xsl:stylesheet element, that way all your literal XHTML elements
will be in the XHTML namespace. Otherwise in any template you write you
will need to make sure that the XHTML default namespace declaration is set
for XHTML elements.
That does it. Thanks again. Corrected and working version:

http://emle.sourceforge.net/emle020000/testb2.xml
http://emle.sourceforge.net/emle020000/testb2.xsl

--
C.W.Holeman II | cw***@Julian5Locals.com -5 | http://JulianLocals.com/cwhii
To only a fraction of the human race does God give the privilege of
earning one's bread doing what one would have gladly pursued free, for
passion. I am very thankful. The Mythical Man-Month Epilogue/F.P.Brooks
Apr 12 '07 #5

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

Similar topics

0
by: Lisa | last post by:
I need to apply the HTML formatting tags and the French accented characters in a XML document. The XML is generated from a database that has HTML tags and French accented characters in the records....
4
by: Invalidlastname | last post by:
Hi, I have an XML document, created from ADO DataSet, which contains XML data in some nodes shown below: <NewDataSet> <Table> <field_name>My Selection</field_name>...
5
by: Amelyan | last post by:
How can I get state of dynamically created controls (RadioButton, CheckBox, TextBox.Text) on post back when I click submit button? The only way I know is by traversing Response.Form enumberator;...
6
by: tentstitcher | last post by:
Hi all: I have a source xml document with an element of type string. This element contains something like the following: <stringData> &lt;Header&gt; &lt;Body&gt; </stringData> I would like to apply an...
2
by: Paul Verbelen | last post by:
I have a file with topics. I like to copy them in another file but want to have some blank lines between the different topics. I use <xsl:text> element with as data some blank lines to perform...
1
by: the_dog_gabby | last post by:
Hello, I have a stylesheet that contains C# functions to generate XML. When I apply the stylesheet to my document, everything works perfectly except the data I get back is escaped like so: ...
0
by: Umagowder | last post by:
All I have my class serialised correctly. I have to apply style sheet to that data and display it in some other format. Everything works fine,I can not read the following xml tag, ...
1
by: andrew_nuss | last post by:
Hi, Something mysterious has happened to my stylus studio project as I've added changes to the XSL file that renders html output. Before, the output included the <HEADand <BODYtags for the HTML...
8
by: ismailc | last post by:
Hi, I would like to change the text color of (<xsl:value-of select="Description") onmouseover of image. the javascript works, it's just that i can seem to get the name correct <td>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.