Re: [docbook] XML + Javascript? was:[Whatever happened too CSS+XML]

From
Bob Stayton <>
Date
2006-01-17T00:25:36+00:00
ID
00cd01c61afc$854b6770$6400a8c0@toshiro
Thread
Re: [docbook] XML + Javascript? was:[Whatever happened too CSS+XML]
You can use the user.head.content template to insert script elements.  See:
http://www.sagehill.net/docbookxsl/InsertExtHtml.html

For example:

<xsl:template name="user.head.content">
  <script src="scripts/website.js" type="text/javascript"></script>

  <script language="javascript">
   <xsl:comment>
     Javascript code goes here.
   // </xsl:comment>
  </script>

</xsl:template>

Getting the browser to execute the code is another thing.  The reference
above describes how to use a processing instruction to insert something in
the output. You can also insert an onLoad attribute in the body element to
do something on loading.  See:

http://www.sagehill.net/docbookxsl/BodyAtts.html

Depending on what you want the Javascript code to do, you may have to do
other customizations.

Bob Stayton
Sagehill Enterprises
DocBook Consulting



----- Original Message ----- 
From: "Doug du Boulay" <>
To: <>
Sent: Friday, January 13, 2006 11:56 PM
Subject: [docbook] XML + Javascript? was:[Whatever happened too CSS+XML]


> I was just rereading the CSS+XML thread from back in November and it
seemed
> that some folk were advocating using javascript to massage a DocBook
document
> to, say build a table of contents or an index on the fly, insert them into
the
> DOM and then render them with CSS.
>
> I was thinking about this when I realised that I don't know how to embed
or
> execute javascript from within XML.
>
> I know that for some browsers you can apply CSS using a leading
>
>   <?xml version="1.0" ?>
>   <?xml-stylesheet href="docbook-css/driver.css" type="text/css" ?>
>
> to render an arbitrary XML document such as DocBook, but
> what is the equivalent to include javascript and have it execute?
>
> In HTML you would just say
>   <script src="scripts/website.js" type="text/javascript">
> or
>   <script language="javascript">
>   <!--
>
>   // -->
>   <script>
>
> I'm sure that javascript could be added in a DocBook element too, but
> how would the browser ever know it had to execute it?
>
> Puzzled.
> Doug
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: 
> For additional commands, e-mail: 
>
>
>