This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: OT: ICFP 2001 (xsl solution?)
Thank you David - I hope someone's going to defend the honour of
xsl-list now that there's no excuse not to!
(BTW, there's a sample document at
http://cristal.inria.fr/ICFP2001/prog-contest/example.txt)
Francis.
David Carlisle wrote:
>
> > will 3 lines do:
>
> having got that far i suppose I'd better finish.
> a) I missed out a > so that would prepend all digits by x not just those
> in tags.
> b) the rules it said to read from stdin and output to stdout
>
> xx.sh
> ===========
>
> sed -e "1 s/^/<foo>/" -e "$ s@\$@</foo>@" -e "s/\\([0-9]>\\)/x\\1/g" > tmp.xml
> java com.icl.saxon.StyleSheet tmp.xml icfp.xsl
>
> icfp.xsl
> ==========
>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0"
> >
>
> <xsl:output method="xml" omit-xml-declaration="yes" indent="no"/>
>
> <xsl:template match="foo">
> <xsl:apply-templates/>
> </xsl:template>
>
> <xsl:template match="*">
> <xsl:copy>
> <xsl:apply-templates/>
> </xsl:copy>
> </xsl:template>
>
> </xsl:stylesheet>
>
> test file xx.x
> ===
> 1
>
> <1>xxx</1>
>
> <b>gg</b>
>
> <9>xxx</9>
> ===
>
> bash$ cat xx.x | ./xx.sh
> ===
> 1
>
> <x1>xxx</x1>
>
> <b>gg</b>
>
> <x9>xxx</x9>
> ===bash$
>
> I suspect that unquoted & are allowed (as no entities except lt and gt)
> if so need another sed rule. but that's it from me:-)
>
> David
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list