Connecting Tech Pros Worldwide Help | Site Map

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

  #1  
Old July 20th, 2005, 08:50 AM
Mike Kamermans
Guest
 
Posts: n/a
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
  #2  
Old July 20th, 2005, 08:50 AM
Martin Honnen
Guest
 
Posts: n/a

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




Mike Kamermans wrote:

[color=blue]
> <script language="JavaScript" version="1.0">
> <!-- commented off to prevent parse errors as usual -->
> </script>[/color]

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.
[color=blue]
> </head>
> <body onLoad="javacsript:addInteraction()">[/color]

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/
  #3  
Old July 20th, 2005, 08:50 AM
Mike Kamermans
Guest
 
Posts: n/a

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


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
  #4  
Old July 20th, 2005, 08:50 AM
Martin Honnen
Guest
 
Posts: n/a

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




Mike Kamermans wrote:

[color=blue]
> 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...[/color]

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/
  #5  
Old July 20th, 2005, 08:50 AM
Mike Kamermans
Guest
 
Posts: n/a

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


Martin,
[color=blue]
> 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.[/color]

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

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
How does this work? Jim Carr answers 2 October 9th, 2006 05:45 AM
character to HTML ampersand escape sequence converter SwordAngel answers 18 July 24th, 2005 12:02 AM
XML (question test) Which language should i use? Weekend answers 9 July 20th, 2005 08:30 AM
Generating HTML from python Philippe C. Martin answers 14 July 19th, 2005 02:59 AM