[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: searching string! Need your help

Subject: Re: searching string! Need your help
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 22 May 2002 11:35:39 -0400
searching a string is xslt
Norm,

At 09:25 PM 5/21/2002, you wrote:
First I would like to thank all of you for all the help you have
provided!!!

I think my problem is very simple but I am having trouble making it to
work.
The xsl code should go through the document and find all the <super>
tags. Instead I get this:

[ERROR]: The markup in the document preceding the root element must be
well-formed.
(The xml file is well-formed but not the .fo file.  )

<xsl:template match="node()">
<xsl:copy>
<xsl:copy-of select="@*"/>
    <xsl:if test="contains(. ,'<sub>')">
       <fo:inline baseline-shift="super" font-size=".75em">
         <xsl:text>FOUND SUPER </xsl:text>
      </fo:inline>
  </xsl:if>
</xsl:copy>
</xsl:template>

As Stuart pointed out, your document isn't well-formed, which is why you are getting this error.


Yet even when you fix this, your technique won't work. This is due to a fundamental misconception you are laboring under with respect to the way XSLT handles a document.

By definition, the XSLT code *cannot* "go through the document and find all the <super> tags". This is because it does not see tags at all. A tag in an XML document is merely, in an XSL system, a notation that indicates the beginning of an element. By the time an XSLT processor sees it, the existence of this element has been noted (that's the job of the parser) and the tag is no more. It's the *element* that you match on or "find". You can't find its beginning apart from finding the whole thing -- and when you do, there won't be any tag there. (It'll have a type name, 'super', but no "tag".)

You are thinking of XSLT as a string-processing routine. It's not. Spend a few minutes on an introductory XSL tutorial and see if it helps illuminate things. Concentrate your attention on the XPath (XSLT) data and processing models.

Once you get the hang of it you'll find it's a very powerful way of working, and fun too.

Enjoy!
Wendell



======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.