473,404 Members | 2,137 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,404 software developers and data experts.

Using XSLT to extend XHTML

I am trying to use XSLT to extend XHTML so that I can have custom
widgets. For example I have a calendar control. Whenever I put the
following in the psudo-XHTML doc:

<calendarbox name="mycal"/>

I get a nice xhtml text box with a calendar icon beside it. When the
calendar icon is clicked a calender pops up to allow the user to choose
the date. Then the value chosen is stuck in the xhtml text field and can
be submitted with the form. I have this working quite well but I have
one problem. My general strategy has been to have my xhtml doc call a
similarly named xsl file. This xsl file imports some general xsl
templates and also imports some xsl templates for specific functionality
used in the xhtml doc. Now some of the imported xsl templates may need
to add stylesheet and script tags to the xhtml head tag. How do I add
this information while still allowing other templates to add their style
and script tags. Let me give you a simplified example:

foo.xhtml
---------
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="/structure/foo.xsl"?>

<html>
<head>
<title>My title</title>
<link rel="stylesheet" type="text/css" href="/style/foo.css"/>
</head>
<body>
<specialwidget/>
</body>
</html>

foo.xsl
-------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">

<xsl:import href="general.xsl"/>
<xsl:import href="widgets.xsl"/>
<xsl:import href="site.xsl"/>

</xsl:stylesheet>

First thing to note is that foo.xhtml could have style and script
information itself. The second thing to note is that any of the imported
xsl files in foo.xsl could add style and script information that their
custom widgets might need.

My goal is to encapsulate the external dependencies that each imported
xsl file needs so that all I have to do is import the xsl file. The
imported style will take care of adding those dependencies to the header.

Any suggestions?

Eric

Jul 20 '05 #1
1 3256
Eric Anderson wrote:
I am trying to use XSLT to extend XHTML so that I can have custom
widgets. For example I have a calendar control. Whenever I put the
following in the psudo-XHTML doc:

<calendarbox name="mycal"/>

I get a nice xhtml text box with a calendar icon beside it. When the
calendar icon is clicked a calender pops up to allow the user to choose
the date. Then the value chosen is stuck in the xhtml text field and can
be submitted with the form. I have this working quite well but I have
one problem. My general strategy has been to have my xhtml doc call a
similarly named xsl file. This xsl file imports some general xsl
templates and also imports some xsl templates for specific functionality
used in the xhtml doc. Now some of the imported xsl templates may need
to add stylesheet and script tags to the xhtml head tag. How do I add
this information while still allowing other templates to add their style
and script tags. Let me give you a simplified example:

foo.xhtml
---------
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="/structure/foo.xsl"?>

<html>
<head>
<title>My title</title>
<link rel="stylesheet" type="text/css" href="/style/foo.css"/>
</head>
<body>
<specialwidget/>
</body>
</html>

foo.xsl
-------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">

<xsl:import href="general.xsl"/>
<xsl:import href="widgets.xsl"/>
<xsl:import href="site.xsl"/>

</xsl:stylesheet>

First thing to note is that foo.xhtml could have style and script
information itself. The second thing to note is that any of the imported
xsl files in foo.xsl could add style and script information that their
custom widgets might need.

My goal is to encapsulate the external dependencies that each imported
xsl file needs so that all I have to do is import the xsl file. The
imported style will take care of adding those dependencies to the header.

Any suggestions?

Eric


You should use a namespace for your controls:

like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="/structure/foo.xsl"?>

<html xmlns:widgets="http://www.yourpage.com/namespace">>
<head>
<title>My title</title>
<link rel="stylesheet" type="text/css" href="/style/foo.css"/>
</head>
<body>
<widgets:specialwidget/>
</body>
</html>

And your xsl could match widges:specialwidget

Hope you understand. Learn more about namespaces too, its really cool
Jul 20 '05 #2

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

Similar topics

0
by: Sergio del Amo | last post by:
Hi, I use the xslt functions provided by php. I am running in my computer the package xampp(www.apachefriends.org) which includes php/apache/mysql .. In this package the php includes the sablotron...
20
by: Bernd Fuhrmann | last post by:
Hi! I have some trouble with some simple stupid XSLT-stuff. My stylesheet: ------------- <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0"...
1
by: Bartek | last post by:
Hello This is my problem: It consider xml 2 xml conversion. source document had unknown structure (xhtml), xslt must process every node, attribute, text, comments etc. from source and write in...
4
by: Pat | last post by:
Is anyone using XML instead of HTML for pages of content? If so is there a public site to browse? Can someone point me to a discussion of the pros and cons of doing this? I am trying to get a...
4
by: Luke Dalessandro | last post by:
I have some XML data that has mixed content XML tags that embed XHTML tags, for instance: <note>Somebody wrote this note in XHTML and wanto to <a href="link.html" target="_new">link</a> to a...
13
by: Tjerk Wolterink | last post by:
Hello i've an xsl stylesheet that must support xhtml entities, my solution: ---- <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE xsl:stylesheet > <xsl:stylesheet version="1.0"...
3
by: Greg | last post by:
Hi, I want to create a web based interface that uses a form + Javascript (in an XHTML namespace) to construct an XPath to query and modify the attributes of some SVG (in an SVG namespace). ...
15
by: Zhang Weiwu | last post by:
http://www.w3.org/MarkUp/2004/xhtml-faq provided a trick to serve xhtml webpage to IE as application/xml I used that trick and now every one of my xhtml webpage have following first 4 starting...
3
by: Andy Dingley | last post by:
>From a thread over in c.i.w.a.h "RFC: From XHTML to HTML via XSLT" http://groups.google.co.uk/group/comp.infosystems.www.authoring.html/msg/f112c230061ffe86 As is well-known, the XSLT HTML...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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,...

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.