[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Comments in XPath / XSLT regular expressions?
> Thanks for your advice on this. I understand now the reasons > behind not allowing newline-ended comments. After reading > Colin Adams comments, and Frans Englich's, I came up with the > following as a best-practice for > ourselves: > > <xsl:variable name="re-extract-filename" > > ^.*? <!-- non-greedy: grab everything --> > ([^/\\]+) <!-- filename in $1 --> > \. <!-- extension-dot --> > [^\.]*$ <!-- extension (not-a-dot*) --> > </xsl:variable> > <xsl:value-of select="replace(., $re-extract-filename, > '$1.xml', 'x')" /> > That seems an excellent suggestion. Putting the regex in a text node rather than an attribute node also means that quote characters don't need to be escaped (and for xsl:analyze-string, curly braces don't need to be doubled). I'd just add one improvement: add the attribute 'as="xs:string"' to the variable declaration, so that the value is a string rather than a document. Michael Kay
|
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
|