This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: searching string! Need your help
- From: Wendell Piez <wapiez at mulberrytech dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 22 May 2002 11:35:39 -0400
- Subject: Re: [xsl] searching string! Need your help
- Reply-to: xsl-list at lists dot mulberrytech dot com
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@mulberrytech.com
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