XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old July 26th, 2003, 07:59 PM
paulx82 paulx82 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Brisbane, Australia
Posts: 19 paulx82 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
DTD and XSLT for HTML Script Tag

I'm in the process of converting my web site from XHTML/CSS to XML/XSLT/CSS. I want to use a single XSLT template for all my XML docs. I can easily add JavaScripts to my XSLT template file, but I don't know how I can add different JavaScripts to my different XML documents, have the XML documents transformed and the JavaScripts work in the resulting documents.

I'm creating my own tags in my dtd, but they are pretty much based on HTML. My DTD excerpt for the script tag is as follows:
<!ELEMENT script (#PCDATA)>
<!ATTLIST script
type CDATA #REQUIRED
src CDATA #IMPLIED
>

I probably will only be referencing external JavaScripts, so I guess I could of done the following:
<!ELEMENT script EMPTY>
<!ATTLIST script
type CDATA #REQUIRED
src CDATA #REQUIRED>

I think my first DTD would enable both inline JavaScript and external javascript files to be referenced, but I'm not sure.

The XSLT code I have tried to use is:
<xsl:template match="script">
<xsl:element name="script">
<xsl:attribute name="type">
<xsl:value-of select="@type"/>
</xsl:attribute>
<xsl:attribute name="src">
<xsl:value-of select="@src"/>
</xsl:attribute>
<xsl:comment>comment inserted for Internet Explorer</xsl:comment>
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>

The <xsl:comment> is because someone mentioned that IE has problems with <script> </script> tags that have nothing in between them.

Of course, my method doesn't work. I can't get my head round XSL, yet.

I won't paste all of my xml,dtd and xslt file, because they are too big, but below is some code that may be relevant.

The start of my xslt file:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
<xslutput method="xml" indent="no" doctype-public="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"; doctype-system="-//W3C//DTD XHTML 1.0 Strict//EN" omit-xml-declaration="no" xml:space="preserve"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">

My current dtd for the script tag:
<!ELEMENT script (#PCDATA)>
<!ATTLIST script
type CDATA #REQUIRED
src CDATA #IMPLIED
>

Part of my XML document:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="http://localhost/inc/xslt/general.xslt"?>;
<!DOCTYPE awddoc SYSTEM "http://localhost/inc/dtd/general.dtd">;
<awddoc>
<head>
<title>title</title>
<script type="text/javascript" src="/inc/js/no_right_click.js">
</script>

I'm a little confused about the use of CDATA sections. My external Javascript file contains
//<![CDATA[
<!--//
at the start of the script
//-->
//]]>
at the end of the script

The script I am using worked before I tried to convert to xml/xslt, so that is not an issue. Any help and/or pointers to specific tutorials on this issue would be most appreciated.

Cheers

Reply With Quote
  #2  
Old July 29th, 2003, 09:52 AM
mrusaw's Avatar
mrusaw mrusaw is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Dallas, Texas
Posts: 138 mrusaw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to mrusaw Send a message via Yahoo to mrusaw
I am not quite sure if i pulled the exact question out of that but let me just tell you what I think.

It looks like you are sucessfully referrencing an external javascript file so my thought is that instead of having all these files to worry about referrencing you should have one common.js that is always called. Then within your common.js you have functions that perform certain actions. So, when you match a template you can wrap your javascript calls around the appropriate elements and receive the desired results.

I hope this wasn't too far off since it is just my thoughts on methodology surrounding the subject.
__________________
mr...

mike.rusaw@realpage.com
RalPage, Inc.

"I have made this letter longer than usual, only because I have not had the time to make it shorter." - Blaise Paschal

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > DTD and XSLT for HTML Script Tag


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway