[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

xhtml xslt?

Subject: xhtml xslt?
From: Nathan Shaw <n8_shaw@xxxxxxxxx>
Date: Wed, 25 Aug 2004 12:56:16 -0700 (PDT)
xhtml xslt
Hi all,

Anyone know of a generic XHTML XSLT? My thought is
this: I often use XHTML inside of custom XML documents
adhering to a custom DTD.

Consider this XML chunk:

<Content>
    <Header Title="What is the OBPR?" />
    <Section>
    	<p>Throughout most of history, human beings have
viewed gravity as an inescapable constant. Gravity has
also profoundly affected the way life on Earth has
evolved.</p>
<p>OBPR works to answer these simple, yet compelling
questions:</p>

			<ol>
				<li>How can we assure the survival of humans
traveling far from Earth?</li>
				<li>How does life respond to gravity and space
environments?</li>
				<li>What new opportunities can research bring to
expand understanding of the laws of nature and enrich
lives on Earth?</li>
				<li>What technology must we create to enable the
next explorers to go beyond where we have
been?</ListItem>
				<li> How can we educate and inspire the next
generation to take the journey? </li>

			</ol>
To output these XHTML elements, I have to create
templates in my XSLT to handle them. What I would like
to do is to find or write one XSLT that I can import
in all of my XSLTs to handle all XHTML output in all
of my XML documents that use XHTML.

I started to create an XSLT to accomplish this:

<!-- br -->
<xsl:template match="xhtml:br">
	<xsl:choose>
		<xsl:when test="normalize-space(@clear)">
			<br clear="{@clear}" />
		</xsl:when>
		<xsl:otherwise>
			<br />
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<!-- pre -->
<xsl:template match="xhtml:pre">
	<pre><xsl:apply-templates /></pre>
</xsl:template>

<!-- a -->
<xsl:template match="xhtml:a">
	<a>
	<xsl:if test="normalize-space(@href)">
		<xsl:attribute name="href"><xsl:value-of
select="@href" /></xsl:attribute>
	</xsl:if>
	<xsl:if test="normalize-space(@class)">
		<xsl:attribute name="class"><xsl:value-of
select="@class" /></xsl:attribute>
	</xsl:if>
	<xsl:if test="normalize-space(@target)">
		<xsl:attribute name="target"><xsl:value-of
select="@target" /></xsl:attribute>
	</xsl:if>
	<xsl:if test="normalize-space(@id)">
		<xsl:attribute name="id"><xsl:value-of select="@id"
/></xsl:attribute>
	</xsl:if>
	<xsl:if test="normalize-space(@name)">
		<xsl:attribute name="name"><xsl:value-of
select="@name" /></xsl:attribute>
	</xsl:if>
	<xsl:apply-templates />
	</a>
</xsl:template>

but I am thinking that I could do something more
generic like this instead:

<!-- copy all nodes and attributes -->
	<xsl:template match="xhtml:node()|@*">
		<!--<xsl:message>Element <xsl:value-of
select="local-name()"/></xsl:message>-->
		<xsl:copy>
			<xsl:apply-templates select="@*|xhtml:node()"/>
		</xsl:copy>
	</xsl:template>

However, the above does a copy, which is not what I
want, as an XHTML element may contain a custom element
inside of it, so I really need to do an
apply-templates instead. Also, I believe the above
will copy all attributes on all nodes right, when I
only want to copy the attributes on xhtml: nodes.

Ideas anyone? Has anyone tackled this issue already?

thanks,

--Nathan


		
_______________________________
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.