xsl-list
[Top] [All Lists]

RE: Processing Entity ' question

2005-02-06 08:14:03
Thank you very much.

Sorry I forgot to say XSL 1.0, but you figured it out correctly.

Greg

-----Original Message-----
From: David Carlisle [mailto:davidc(_at_)nag(_dot_)co(_dot_)uk] 
Sent: Saturday, February 05, 2005 7:21 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Processing Entity ' question


Are you using XSLT2/Xpath2?

In each case it acts like there are missing end parenthesis, no doubt
because the odd number of single quotes act like one quote.  

No (unless you are using Xpath2, which I suspect isn't the case)
All three of the things you tried are equivalent to ''' (enity and
character references are expanded before Xpath is parsed) so are an
empty string followed by a trailing ' which is a ayntax error.

The FAQ has entries on this but basically, start from the Xpath you need
and worry about xml quoting later.

You want the string literal "'" (you have to use " to delimit a string
literal involving a ' in Xpath 1)
so you want the XPath

string-length(string-before($myValue,"'"))>0

(or equivalently
  starts-with($myValue,"'")
)

As far as XML is concerned, the above may as well be
jhgkjg"nbfjh'
just some random string involving " and '
to get that into an attribute you always have two choices
delimit with " and quote any " or delimit with ' and quote any '

so
test="string-length(substring-before($myValue,"'"))>0"

or

test='string-length(substring-before($myValue,"'"))>0'

If you are using Xpath2 then a doubleed ' (or ") counts as a single ' in
a string literal so you could then do

test='string-length(substring-before($myValue,''''))>0'

which avoids using xml quotes at all, although I'm not sure it's any
more readable.

Incidentally
   In the file is it properly represented with  an internal entity.  The
   XML looks like <LogicalFieldName>Broker&apos;s ZIP</LogicalFieldName>

You could of course use ' rather than &apos;; in the source although
that wouldn't change the XSLT required.

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>
--~--




--~------------------------------------------------------------------
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>
--~--



<Prev in Thread] Current Thread [Next in Thread>