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

Dealing with markup not known in advance

Subject: Dealing with markup not known in advance
From: Clark Cooper <coopercl@xxxxxxxxxx>
Date: Wed, 14 Oct 1998 14:50:22 -0400 (EDT)
xsl node
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:template match="foo">
  <newfoo attr="bar">

<xsl:template match="foo//*">

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(.)}">

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"/>
<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


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.
First Name
Last Name
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.