Subject: [xsl] Re: XSL-List Digest V4 #273 From: David Chryst <dchryst@xxxxxxxxx> Date: Wed, 17 Apr 2002 10:37:54 -0700 (PDT) |
Jacob, first, your input XML needs to be well-formed, that is all attribute values must be contained in single- or double-quotes, you must have exactly 1 root element (named any name) and every element must be closed. Second, suppose your input now looks like this: <root> <INPUT TYPE="text" name="q" size="12" maxlength="255" value=""/> <INPUT type="submit" name="btnG" VALUE=" Google "/> <input size="30" name="p"/> <input type="submit" value="Search"/> </root> you can in 1 template use an xsl:choose element to handle an input element with a type=submit differently than other types of input elements. try this XSL: <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" /> <xsl:template match="INPUT"> <xsl:call-template name="ProcessInputElement"/> </xsl:template> <xsl:template match="input"> <xsl:call-template name="ProcessInputElement"/> </xsl:template> <xsl:template name="ProcessInputElement"> <xsl:variable name="MyType" select="concat(@TYPE, @type)"/> <xsl:choose> <xsl:when test="translate($MyType, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') = 'submit'"> <xsl:variable name="MyLabel" select="concat(@VALUE, @value)"/> <do type="accept" label="{$MyLabel}"/> </xsl:when> <xsl:otherwise> <xsl:variable name="MyName" select="concat(@NAME, @name)"/> <xsl:variable name="MySize" select="concat(@SIZE, @size)"/> <xsl:variable name="MyMaxlength" select="concat(@MAXLENGTH, @maxlength)"/> <input name="{$MyName}" size="{$MySize}" maxlength="{$MyMaxlength}"/> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> > I want to write a generic conversion that will > convert: > > <FORM method=GET > action="http://www.google.com/search"> > <INPUT TYPE=text name=q size=12 maxlength=255 > value=""> > <INPUT type=submit name=btnG VALUE=" Google "> > </FORM> > > to: > > <input name="q" size="12" maxlength="255"> > <do type="accept" label="Google"> > > > And also convert: > > <input size=30 name=p> > <input type=submit value=Search> > > to: > <input name="p" size="30"> > <do type="accept" label="Search"> > > > Is this possible to do with one template?? I just > don't seem to know > how to approach this. Can anybody help? > > Jacob Glenn > > > > XSL-List info and archive: > http://www.mulberrytech.com/xsl/xsl-list > > ------------------------------ > > Date: Tue, 16 Apr 2002 09:41:13 +0300 (EEST) > From: Jarkko.Moilanen@xxxxxx > Subject: RE: [xsl] count element content length > > Lainaus Jarno.Elovirta@xxxxxxxxx: > > > Heppa, > > > > > Is there some method to count the elements > content length and when > > > for example the 20th character is met, then it > would stop showing > > > the rest and put ... after that. Because of my > lowsy english, here > > > is one example: > > > > > > elements content: > > > <Subject id="0000000002">Chattaamaan city > chattiin ke klo 12</Subject> > > > > > > the result should be: > > > <p>Chattaamaan city cha...</p> > > > > <xsl:template match="Subject"> > > <p> > > <xsl:value-of select="concat(substring(., 1, > 20),'...')" /> > > </p> > > </xsl:template> > > > > But you might want to consider breaking the string > at word boundary > > You are right, but I am not at that level yet =) > But hey! If I do like Santtu suggested, the result > is a bit wrong since > it adds "..." also to elements that are shorter than > 20 characters. What to do? > > Cheers Jarkko > > > > > Cheers, > > > > Santtu > > > > XSL-List info and archive: > http://www.mulberrytech.com/xsl/xsl-list > > > > > > > > ******************************************************************* > Jarkko Moilanen *You are wise, witty, and > wonderful, * > Researcher/ ITCM *but you spend too much time > * > jarkko.moilanen@xxxxxx *reading this sort of trash. > * > www.uta.fi/~jm60697 * > * > GSM: +358 50 3766 927 * > * > ******************************************************************* > * ITCM Information Technology and Crisis Management > * > ******************************************************************* > > XSL-List info and archive: > http://www.mulberrytech.com/xsl/xsl-list > > ------------------------------ > > Date: Tue, 16 Apr 2002 15:01:32 +0800 > From: tanska@xxxxxxxxxxxxxxx > Subject: [xsl] XML file not able to view on certain > machines > > Able to view the same XML with the XSL on certain > machines with Internet > Explorer 6, but not able to view the XML with the > XSL format on certain > machines. > > > > > > [This e-mail is confidential and may also be > privileged. If you are not the > intended recipient, please delete it and notify us > immediately; you should > not copy or use it for any purpose, nor disclose its > contents to any other > person. Thank you.] > > > XSL-List info and archive: > http://www.mulberrytech.com/xsl/xsl-list > > ------------------------------ > > Date: Tue, 16 Apr 2002 10:49:53 +0300 > From: Jarno.Elovirta@xxxxxxxxx > Subject: RE: [xsl] count element content length > > Heppa, > > === message truncated === __________________________________________________ Do You Yahoo!? Yahoo! Tax Center - online filing with TurboTax http://taxes.yahoo.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: XSL-List Digest V4 #275, David Chryst | Thread | [xsl] Getting rid of namespace attr, Francois Rautenbach |
[xsl] Re: XSL-List Digest V4 #275, David Chryst | Date | [xsl] Getting rid of namespace attr, Francois Rautenbach |
Month |