RE: Is XHTML a dead end?

On Fri, 2002-09-27 at 19:15, Didier PH Martin wrote:

> Didier replies:
> I would probably would do that myself but now we end up with something
> more complex then SGML architectural forms. Also, I didn't achieve the
> goal to write a generic linking stylesheet that I can re-use. Thus, we
> achieved something less useful than SGML+DSSSL. Is this what we call
> entropy? Degradation of the matter with time :-)

Since you seem to feel that it's an important issue, I have done the exercise and that's not *that* complex!

Source:

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:hlink="http://www.w3.org/2002/06/hlink"
xmlns:vdv="http://eric.van-der-vlist.com/whatever">
<head>
<hlink:hlink namespace="http://www.w3.org/1999/xhtml"
       element="img"
       locator="@src"
       effect="embed"
       actuate="onLoad"
       onFailure="warn"/>
</head>
<body>
<br vdv:foo="bar"/>
<img src="whatever" vdv:foo="bar"/>
</body>
</html>

XSLT (could easily be adapted to external HLinks):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
  xmlns:xhtml="http://www.w3.org/1999/xhtml"
	xmlns:hlink="http://www.w3.org/2002/06/hlink"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >

	<xsl:template match="@*">
		<xsl:param name="hlink"/>
		<xsl:if test="not(concat('@', name()) = $hlink/@locator)">
			<xsl:copy>
				<xsl:apply-templates/>
			</xsl:copy>
		</xsl:if>
	</xsl:template>

	<xsl:template match="*">
		<xsl:copy>
			<xsl:variable name="hlink"
select="/xhtml:html/xhtml:head/hlink:hlink[@element=local-name(current()) and @namespace=namespace-uri(current())]"/>
			<xsl:apply-templates select="$hlink/@*" mode="hlink">
				<xsl:with-param name="node" select="."/>
			</xsl:apply-templates>
			<xsl:apply-templates select="@*">
				<xsl:with-param name="hlink" select="$hlink"/>
			</xsl:apply-templates>
			<xsl:apply-templates/>
		</xsl:copy>
	</xsl:template>
	
	<xsl:template match="@*" mode="hlink"/>
	<xsl:template match="@element" mode="hlink">
		<xsl:attribute name="xlink:type"
namespace="http://www.w3.org/1999/xlink">
			<xsl:text>simple</xsl:text>
		</xsl:attribute>
	</xsl:template>
	<xsl:template match="@effect" mode="hlink">
		<xsl:attribute name="xlink:show"
namespace="http://www.w3.org/1999/xlink">
			<xsl:value-of select="."/>
		</xsl:attribute>
	</xsl:template>
	<xsl:template match="@actuate" mode="hlink">
		<xsl:attribute name="xlink:actuate"
namespace="http://www.w3.org/1999/xlink">
			<xsl:value-of select="."/>
		</xsl:attribute>
	</xsl:template>
	<xsl:template match="@locator" mode="hlink">
		<xsl:attribute name="xlink:href"
namespace="http://www.w3.org/1999/xlink">
			<xsl:value-of select="."/>
		</xsl:attribute>
	</xsl:template>
	<xsl:template match="@locator[starts-with(., '@')]" mode="hlink">
	  <xsl:param name="node"/>
		<xsl:attribute name="xlink:href"
namespace="http://www.w3.org/1999/xlink">
			<xsl:value-of select="$node/@*[name() = substring-after(current(),
'@')]"/>
		</xsl:attribute>
	</xsl:template>

<!-- more attributes to be defined -->

</xsl:stylesheet>

Result:

vdv@ibook:~/repros/libxslt$ xslt hlink.xml hlink.xsl 
using libxslt
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:hlink="http://www.w3.org/2002/06/hlink"
xmlns:vdv="http://eric.van-der-vlist.com/whatever">
<head>
<hlink:hlink namespace="http://www.w3.org/1999/xhtml" element="img"
locator="@src" effect="embed" actuate="onLoad" onFailure="warn"/>
</head>
<body>
<br vdv:foo="bar"/>
<img xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple"
xlink:href="whatever" xlink:show="embed" xlink:actuate="onLoad"
vdv:foo="bar"/>
</body>
</html>


Enjoy,

Eric

-- 
Rendez-vous à Paris.
                          http://www.technoforum.fr/integ2002/index.html
------------------------------------------------------------------------
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
(W3C) XML Schema ISBN:0-596-00252-1 http://oreilly.com/catalog/xmlschema
------------------------------------------------------------------------

Received on Friday, 27 September 2002 14:38:56 UTC