xsl-list
[Top] [All Lists]

Re: Returning HTML tags from a function not working

2006-01-27 08:06:53

what are you passing as the input to this function?

your parameter is called docnode, but you can not be passing teh
document node as it is typed as element()* and document nodes are
necessarily not elements.

If $docnode is empty, you return nothing, and if it is non empty
you pass it to xsl:analyze-string whic as it's name implies expects a
string as its select expression not a sequence of elements.

So if you have nore than one element in $docnode you will get an error
and if there is just one element in $docnode you will analyze teh string
value of that element (ie just take all the character data, ignoring any
elements).

Note that XSLT has _no_ access to the tags in an input document, they
are all resolved by an XML parser before XSLT starts.

I suspect you want to start with an identity transform then add a
template

<xsl:template match="text()">
    <xsl:analyze-string  select="." regex="\n">
       <xsl:matching-substring><br /></xsl:matching-substring>
       <xsl:non-matching-substring>
         <xsl:value-of select="normalize-space(.)"/>
       </xsl:non-matching-substring>
     </xsl:analyze-string> 
</xsl:template>

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--