- From: G. Ken Holman <gkholman@CraneSoftwrights.com>
- Date: Thu, 15 Aug 2002 19:14:13 -0400
- To: www-xsl-fo@w3.org
At 2002-08-14 08:30 -0400, Wolfgang.Schreurs@ingbank.com wrote: >The input would be: ><portal_banner> ><spotlight_text ID="texthref">bla bla <a >href="http://www.apple.com">apple</a> bla </spotlight_text> ><spotlight_image>/content/image_bank/feature_images/mngmnt_update_deBaas.gif ></spotlight_image> ><spotlight_image_href><http://www.apple.com></spotlight_image_href> ></portal_banner> >This is the XML file... >---------------------------------------------------------------------------- >---------------------------------------------------------------- >The desired output from the XSL file would be: >bla bla apple <http://www.apple.com> bla >---------------------------------------------------------------------------- >---------------------------------------------------------------- >where there is a limit of 60 chars, but we allready have the limit by using >this code in the XSL file: >(I think I can keep this the way it is.) No, I'm sorry I wasn't clear before but you cannot use any function on the length of the markup. XSLT is for manipulating nodes, not manipulating markup. ><xsl:template name="substring_template"> ><xsl:variable name="right_text_string" select="spotlight_text"/> ><xsl:value-of select="substring($right_text_string,0, 60)"/> ></xsl:template> >---------------------------------------------------------------------------- >---------------------------------------------------------------- >How would I get the desired output? Currently it shows the line of text, but >the hyperlink isn't used, it looks like substring() removes the '<a >href="...">...</a>' tags, but keeps the input between the tags. ie, I get >this output: >bla bla apple bla Yes, because substring() infers string() on the first argument which looks at the text nodes and gives you only the concatenation of the text nodes without any markup. If you are processing <spotlight_text>, then do the following: <xsl:template match="spotlight_text> <xsl:copy-of select="node()"/> </xsl:template> The above will copy all nodes from your input tree to your result tree and when those result tree nodes are serialized as syntax you will get the hyperlink restored. You will *not* be able to measure the length of the markup, so you will not be able to reliably restrict the output to only 60 characters total. You will have to use a different technology to get that kind of control over the generated markup. >I hope this is better to understand. I hope it has been successfully conveyed that you are asking about working with markup, yet XSLT only works with abstract nodes of a node tree. >I don't use the Formatting Object >(xsl:fo) Then I suggest you ask future questions to: http://www.mulberrytech.com/xsl/xsl-list I hope this helps. ................. Ken -- Upcoming hands-on in-depth 3-days XSLT/XPath and/or 2-days XSL-FO: - North America: Sep 30-Oct 4,2002 - Japan: Oct 7-Oct 11,2002 G. Ken Holman mailto:gkholman@CraneSoftwrights.com Crane Softwrights Ltd. http://www.CraneSoftwrights.com/f/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995) ISBN 0-13-065196-6 Definitive XSLT and XPath ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-07-1 Practical Formatting Using XSLFO XSL/XML/DSSSL/SGML/OmniMark services, books (electronic, printed), articles, training (instructor-live,Internet-live,web/CD,licensed) Next public training: 2002-08-26,27,09-30,10-03,07,10
Received on Thursday, 15 August 2002 19:17:37 UTC