473,320 Members | 2,161 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.

How do I make a mix of html/xml work?

I have an XML document that, in order to save b/w for both server and
users, uses a few emtpy tags a la "<add/>" and "<edit/>" in the source,
which [should] get javascript replaced once the document is done loading
into their full form (for <add/>, this would be something like <img
src="add.gif" border="0" onClick="javascript:handleEvent(this,'add')">).

In order to do this I figured the documented needed to use a few html
tags as well (mainly, it needed head, title, script and body), but I'm
not quite certain how to make this work. I've changed my dtd to read:

<!element html (head, body)>
<!element head (title, script)>
<!element title (#PCDATA*)>
<!element script (#PCDATA*)>
<!attlist script language CDATA #REQUIRED>
<!attlist script version CDATA #REQUIRED>
<!element body (list)>

where the[list] element is the root node of my own XML data. The xml
file itself looks like:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<?xml-stylesheet href="nr-kvis.css" type="text/css"?>
<!DOCTYPE html SYSTEM "NR-jouyou.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>???? level 1 (80 ??)</title>
<script language="JavaScript" version="1.0">
<!-- commented off to prevent parse errors as usual -->
</script>
</head>
<body onLoad="javacsript:addInteraction()">
<list xmlns="http://www.nihongoresources.com/jouyou">
[...xml in the nihongoresources namespace...]
</list>
</body
</html>

When I load this in firefox (quite a nice browser that's very xml
friendly) the javascript is never called.

A second issue is that if I include an html namespace element inside the
<list> content using for instance:

<html:img src="someimage.gif"/>

upon validation I get the error that "the html namespace is not bound". I
know that the xml I use changes the default namespace to list's namespace
while inside the list element, but I didn't know it voided html's as
well.. how do I bind and element to a namespace so I can use it anywhere
in my xml?

- Mike Kamermans
www.nihongoresources.com
Jul 20 '05 #1
4 5709


Mike Kamermans wrote:

<script language="JavaScript" version="1.0">
<!-- commented off to prevent parse errors as usual -->
</script>
That should be
<script type="text/javascript">
//<![CDATA[

//]]>
</script>
don't use <!-- --> to comment out the script code as then it is
commented out and not passed to the script engine.
</head>
<body onLoad="javacsript:addInteraction()">


XHTML is case-sensitive:
<body onload="addInterval();">
then I think it should work (if you serve up the XHTML with the proper
content type application/xhtml+xml).

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
implementing the xhtml changes has it loading, but now I'm facing another
problem... how to get the element node that called a javascript function.

In html context this could be done using 'this', and making the javascript
function have an event as argument, then calling event.target in body of
the function and working with that - in xhtml context this doesn't seem to
work... is there another keyword that can be used (or fetch instruction)
that allows me to figure out which element called a function that you know
of?

- Mike Kamermans
www.nihongoresources.com
Jul 20 '05 #3


Mike Kamermans wrote:

how to get the element node that called a javascript function.

In html context this could be done using 'this', and making the javascript
function have an event as argument, then calling event.target in body of
the function and working with that - in xhtml context this doesn't seem to
work...


It should work, the W3C DOM Events model applies to both HTML and XHTML
so scripting events shouldn't change with Mozilla whether you serve
text/html or application/xhtml.
If you have problems to get it to work then make a small test case and
post it here or better even post its URL.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #4
Martin,
It should work, the W3C DOM Events model applies to both HTML and
XHTML so scripting events shouldn't change with Mozilla whether you
serve text/html or application/xhtml.
If you have problems to get it to work then make a small test case and
post it here or better even post its URL.


I've posted a new message with a URL under the subject "using "this" in
javascript/XHTML". Maybe you can spot an obvious mistake in the file that
I'm overlooking...

Regards,

Mike

Jul 20 '05 #5

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

Similar topics

71
by: tomy_baseo | last post by:
I'm new to HTML and want to learn the basics by learning to code by hand (with the assistance of an HTML editor to eliminate repetitive tasks). Can anyone recommend a good, basic HTML editor that's...
10
by: VictorG | last post by:
Hello, I am new to JS and am trying to add some HTML into a JS function. So that when called the script as well as the HTML will be invoked. Is there some type of embed mechanism, sort of the...
4
by: frogman042 | last post by:
My daughter is playing around trying to learn JavaScript and she wrote a small program that prints out a message in increasing and decreasing font size and color changes. She is using document...
20
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just...
9
by: Jason Gogela | last post by:
Does anyone out there know why I should care whether a <span> is nested in a <p> or vice versa? What is the bennafit of adhering to this standard? It seems to me that regardless of which way you...
59
by: Lennart Björk | last post by:
Hi All, I have a tiny program: <!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>MyTitle</title> <meta...
7
by: pamelafluente | last post by:
The precious input given by Laurent, Martin, Benjamin about XMLHttpRequest in Javascript, has made me think that perhaps I could improve what I am currently doing by using Ajax. Let's make it...
2
by: justplain.kzn | last post by:
Hi, I have a table with dynamic html that contains drop down select lists and readonly text boxes. Dynamic calculations are done on change of a value in one of the drop down select lists. ...
14
by: jcage | last post by:
Is there any tutorials online for sending email through forms? I can send an email as well as write to my MySQL database from home with the following code but not at work. I think there might be...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
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....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.