Lopping off Element Type names with substring-after

Subject: Lopping off Element Type names with substring-after
From: John Robert Gardner <John.Robert.Gardner@xxxxxxxxxxxx>
Date: Mon, 14 Aug 2000 12:25:59 -0400 (EDT)
Whyizzit that the simple things seem most difficult.

Take a slew of tag names (please, _take_ them) like MyBusiness.process.shipment, 
AnotherBusiness.process.payment, etc.  I want to output the entire tree, only I 
want to use substring-after to lop off whatever follows the first "." in the 
element type names that have periods (with the exception of a couple tags).

source (something like)
	<MyBusiness>
		<MyBusiness.process.shipment>stuff</MyBusiness.process.shipment
		<MyBusiness.process.payment>
			more stuff</MyBusiness.process.payment>
		<OrKeepThis.kind.of.tag>
			complete tag retained</OrKeepThis.kind.of.tag>
	</MyBusiness>
	<YourBusiness>
		<YourBusiness.process.shipment>
			stuff</YourBusiness.process.shipment
		<YourBusiness.process.payment>
			more stuff</YourBusiness.process.payment>
		<AndKeepThis.kind.of.tag>
			complete tag retained</AndKeepThis.kind.of.tag>
	</YourBusiness>

script

<!-- to copy the whole tree -->
	
	<xsl:template match="/">
		<xsl:copy-of select="@*|*|text()" />
	</xsl:template>
	
<!-- to trim most, but not all, the tag names -->
	
	<xsl:template match="//*[not(contains(name(), 'AndKeep'))
		and not(contains(name(), 'OrKeep'))]">
		<xsl:copy-of select="*[substring-after(name(), '.')]" />
	</xsl:template>
	
 . . . I'm getting all kinds of gibberish, with the OrKeep and AndKeep at the 
top of a double-size output (double the size of the input) where all the full 
 tag names are still not even lopped off. 
 
 I figure two basic problems here, which--I regret--cover the entire endeavor:
 I'm not effectively replicating the inp[ut source (I'm iterating parts of it), 
and I'm not effectively implementing the lopping-off with substring-after().
 
 Suggestions?
 
 jr


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread