473,804 Members | 3,461 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

<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:styleshe et 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.dt d"
/>

<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.dt d"><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.evalua te("//span",
document, null, XPathResult.FIR ST_ORDERED_NODE _TYPE, null)
..singleNodeVal ue; var div = document.evalua te("//xhtml:div", document,
lu, XPathResult.FIR ST_ORDERED_NODE _TYPE, null) .singleNodeValu e;
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***@Julian5Lo cals.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 2113
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:styleshe et 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.dt d"
/>

<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.dt d">
<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.evalua te("//span",
document, null, XPathResult.FIR ST_ORDERED_NODE _TYPE, null)
.singleNodeValu e;
var div = document.evalua te("//xhtml:div",
document, lu, XPathResult.FIR ST_ORDERED_NODE _TYPE, null)
.singleNodeValu e;
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***@Julian5Lo cals.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:styleshe et 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.netwro te in message
news:461e4471@k cnews01...
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*******@yaho o.dewrote in message
news:46******** *************** @newsspool4.arc or-online.net...
C.W.Holeman II wrote:
><xsl:styleshee t version="1.0"
xmlns:xsl="htt p://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***@Julian5Lo cals.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
1966
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. I have specified <xsl:output method="html"/> and encoding="iso-8859-1". When I apply the xsl:value-of and set the disable-output-escaping to "yes", the HTML formatting tags are displayed correctly, but the French accented characters are...
4
3725
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> <field_type>dropdown</field_type> <field_choice_text>
5
3524
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; Response.Form.GetEnumerator(), etc. while, identifying specific controls by programmatically assigned unique id (e.g. MyButton_AnswerID_123). However, I am not sure if that is the proper way. What is the common practice?
6
24380
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 XSLT and replace all occurances of &lt; with < and &gt; with >.
2
1823
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 this. To clarify my question, I have add all the files required to perform the test. First question: Why doesn't this works anymore if I remove the line with "&#x00A0;" in the XSL-file ?
1
1756
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: &lt;test&gt;this is a test&lt;/test&gt; I need to get <test>this is a test</testrather than the escaped data. Any input would be appreciated.
0
1716
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, <PrescriptionRefillMeds> <anyType xsi:type="PrescriptionRefillMed"> <Description>Drug1</Description> I have written code to conert the object in to the serialising/deserialising in C#. XSLT has the required namespacses also,not able to read the...
1
1549
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 output, even though I did nothing explictly to cause this. Now, they are missing in the HTML output. Is this a project setting in stylus studio, or is it an artifact of the various apply-template commands in the XSL file? Or something else. ...
8
12458
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> <xsl:value-of select="Description" disable-output-escaping="yes" /> </td> <td> <xsl:element name="asp:image"> <xsl:attribute name='id'>ttip_<xsl:value-of select='@name' /></xsl:attribute>
0
9705
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...
0
10567
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10310
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
10074
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9138
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...
1
7613
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
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();...
1
4291
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
3
2983
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.