Subject: Matching on elements from namespaces From: zun@xxxxxxxxxxxxxx Date: Thu, 21 Oct 1999 16:31:20 -0400 (EWT) |
Hi everyone, I've run across two interesting issues in matching elements from namespaces. The end goal is to have several stylesheets, each of which process elements from a particular namespace, and then have a master stylesheet which imports these stylesheets. For example, I might want an XHTML stylesheet and a MathML stylesheet which when combined together will generate HTML from a mixed XHTML/MathML document. What I'm finding is that writing the XHTML stylesheet is cumbersome. With the latest version of XT and the following source: <html xmlns="http://www.w3.org/TR/xhtml1/strict"> <head> <title>Example page</title> </head> <body>Some stuff</body> </html> I have to write a stylesheet like the following: <xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0" xmlns:xhtml="http://www.w3.org/TR/xhtml1/strict"> <xsl:output method="html"/> <xsl:template match="/xhtml:html/xhtml:body"> <xsl:copy-of select="text()|xhtml:*"/> </xsl:template> </xsl:stylesheet> Note the nasty match and select expressions. Now according to XPath section 2.3 Node Tests, A QName in the node test is expanded into an expanded-name using the namespace declarations from the expression context. This is the same way expansion is done for element type names in start and end-tags except that the default namespace declared with xmlns is not used: if the QName does not have a prefix, then the namespace URI is null (this is the same way attribute names are expanded). For future versions of XSLT/XPath, what do you feel should be the best way to reduce the clutter? How about an inputns attribute, so I can write something like: <xsl:template match="/html/body" inputns="http://www.w3.org/TR/xhtml1/strict"> <xsl:copy-of select="text()|*"/> </xsl:template> or an input-prefix attribute: <xsl:template match="/html/body" input-prefix="xhtml"> <xsl:copy-of select="text()|*"/> </xsl:template> The second issue relates to my desire for having a separate stylesheet per namespace. Right now, both xsl:include and xsl:import must be top-level elements. If I have several hundred namespaces this can get unwieldy and so I would like to have a facility to include only those stylesheets which are currently applicable to the document at hand. That is, perhaps a top level element to indicate a mapping between namespace and stylesheet. Comments? . . . Sean. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
ANN: 4XSLT 0.7.2, uche . ogbuji | Thread | Re: Matching on elements from names, James Clark |
Re: XSL and the DOM, Jon Smirl | Date | Re: XSL FOs -> PDF using InDesign, Sebastian Rahtz |
Month |