[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Lopping off Element Type names with substring-after
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|