Subject: [xsl] Re: need help with converting attribute into elements From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx> Date: Tue, 14 Oct 2003 21:19:47 +0200 |
"Ale¹ Peregrin" <ales.peregrin@xxxxxxxxxx> wrote in message news:006001c3922f$ae0865d0$1c0aa8c0@xxxxxxxx > Hi! > I'm trying to make a XSLT stylexheet for transforming XML document into HTML > and there is a problem I'm unable to solve, even after a week of trying and > searching all over the internet. The problem looks quite easy to me and it > seems I'm missing something important about XSL language. Here it goes: > > I have an XML tag which looks like this: <text bold=true italic=true > underline=false>Help!</text> > In this case, the result in HTML should be: > <font> > <b> > <i> > Help! > </i> > </b> > </font> > > I simply need to transform the attributes into HTML elements so that any of > the possible combinations of the atributes' values would be transformed > correctly. > The transformation below does this. It is essentially the same as the one proposed by Jarno (and in fact I remember writing almost the same a month or two ago), but saving a few lines, because it doesn't use a mapping for the names of the elements. This is not at all something too complex -- in fact the code fits on one screen. Try to do the same in another programming language with smaller number of lines of code. The XSLT 2.0 solution provided by Mike is not significantly shorter either. I think that only very simple programs consist of less than thirty lines of code. The problem at hand is not simple at all, as it requires a radical structural transformation. Therefore, the provided solutions are all compact and ellegant and also quite simple. The XSLT 1.0 solution uses just one recursively called named template, which distinguishes two cases -- in one it simply calls itself, in the other case it agai calls itself but within a created element. ===== Cheers, Dimitre Novatchev. http://fxsl.sourceforge.net/ -- the home of FXSL XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] need help with converting, andrew . curry | Thread | RE: [xsl] need help with converting, Rod Humphris - FLPTN |
Re: [xsl] Problem sending node Arra, Wendell Piez | Date | RE: [xsl] badly need xsl help(prob , Murali Korrapati |
Month |