|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: remove extra chars from the entire xml document
Arbee Shadkam wrote:
> thanks Roland for the reply, Bu my xml document is gigantic, so i can not
> have a translate function for each tag. I was wondering if there would be a
> better way like a template to apply to the entire document?
Do an identity transformation (recurse through document, copying every node),
and for text nodes, translate before copying. I assume by 'fields' you mean
text node children of element nodes. You could easily adapt it to do
attribute nodes as well.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="no"/>
<xsl:variable name="deleteThese">&'*</xsl:variable>
<xsl:template match="/|*">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*|comment()|processing-instruction()">
<xsl:copy/>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="translate(.,$deleteThese,'')"/>
</xsl:template>
</xsl:stylesheet>
- Mike
____________________________________________________________________________
mike j. brown | xml/xslt: http://skew.org/xml/
denver/boulder, colorado, usa | resume: http://skew.org/~mike/resume/
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
|






