Subject: Dealing with markup not known in advance From: Clark Cooper <coopercl@xxxxxxxxxx> Date: Wed, 14 Oct 1998 14:50:22 -0400 (EDT) |
Say I want to transform a certain element in a document, perhaps putting a wrapper element, or adding attributes, but want to keep the content exactly the same, *including the existing markup.* We may not know in advance all the different kinds of markup elements that might be slipped into the class of documents that this stylesheet is to be applied to. The motivation for this could be that we want only to re-arrange the ordering of the middle layers of the document, leaving the lower level markup intact. So perhaps we're making an outline look different but the equivalent to html character level markup would remain the same. I've been trying to teach myself XSL with James Clark's XT package and I don't see how to do this with the current XSL. What I think I'd need to do this would be something like this: <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> ... <xsl:template match="foo"> <newfoo attr="bar"> <xsl:process-children/> </newfoo> </xsl:template> <xsl:template match="foo//*"> <xsl:current-node> <xsl:process-children/> </xsl:current-node> </xsl:template> ... </xsl:stylesheet> The <xsl:current-node> gets replaced with the current start-tag, including attributes, and the end tag changes in a similar way. If this were added to the language, then there should also be a way to add, replace, or remove attributes. ================ A more general notion would be an output node with parameterized type along with a way to access element names via the {} mechanism <xsl:node name="{element(.)}"> ... </xsl:node> Where element can contain (for instance): . current element .. parent element / root element id(xx) element with given id This could be useful inside macros (even without the {element()} template). Addition or replacement of attributes within can be taken care of this way: <xsl:node-attr name="xyz" value="42"/> <xsl:node-attr-set from="."/> (the from value should resolve to an element in the source doc from which we'll get attributes to merge into this node) Removal of attributes can be dealt with thusly: <xsl:node-attr-remove name="xyz"/> or <xsl:node-attr-remove name="*"/> to delete all attributes. -- Clark Cooper Logic Technology Inc. cccooper@xxxxxxxxxxxxx (518) 385-8380 650 Franklin St., Suite 304 coopercl@xxxxxxxxxx Schenectady, NY 12305 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: The XSL-List Digest V1 #181, Paul Prescod | Thread | Re: Dealing with markup not known i, Paul Prescod |
Re: XSL formatting objects to HTML, \"Pasqualino \\\"Tit | Date | Hyperlinks and XSL, Bethany Close |
Month |