|
|||||||
| XML Discussion and technical support for using and deploying XML applications and websites. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
using xsl for root element
This is an xml file, that is to be transformed to html document
HTML Code:
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="article1.xsl"?> <article> <headline>Blowing XML Bubbles</headline> | | HTML Code:
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns="http://www.w.org/1999/XSL/Transform"> <xsl:output method="html" /> <xsl:template match="/"> <HTML> <HEAD> <TITLE> <xsl:value-of select="article/headline"> | | HTML Code:
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns="http://www.w.org/1999/XSL/Transform"> <xsl:output method="html" /> <HTML> <HEAD> <TITLE> <xsl:value-of select="/article/headline"> | | HTML Code:
<xsl:template match="bold"> <B> <xsl:apply-templates /> </B> </xsl:template> Please explain in detail as reading from book did not help |
|
#2
|
||||
|
||||
|
Try it both ways.
__________________
“The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.” —Tim Berners-Lee, W3C Director and inventor of the World Wide Web |
|
#3
|
||||
|
||||
|
just think of each template as a chunk of the final output.
the more chunks you have, the easier it is to re-arrange the output. you don't need a root template, but it sure helps. you will probably find xml "leaking out" if you don't use one. you can have as many templates as you like, each with a specific purpose. you seem to be using match and apply, but i like name and call better; it's more specific. everytime <xsl:apply-templates /> is called, every template is examined to see if it's match attrib matches the current node context. If it does, the results of the template evaluation are inserted into the place where the <xsl:apply-templates /> is.
__________________
libs: mini (updated) ASPmini myIO (new) dnd tmpl8 apps: snippets blog photos crypto image editor crapplets: json browse json view compressor time grads |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|