Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 27th, 2009, 02:52 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 109
Thanks: 18
Thanked 0 Times in 0 Posts
Default Need to build regex to find specific hex characters

Hi,

I have a statement: <xsl:analyze-string select="$cmdSyntax" regex="^([A-Z0-9]+)-.*$">

that I need to adjust.

Rather than just looking for the dash after the alpha numerics, I need to search for a specific string of hex characters (xE2, x80 then x91). They will all three be there for the targets I'm looking for.

I'm not seeing how to build a regex that locates specific hex values.

Can you help?

Thanks,

- mike
__________________
------------------------
Keep Moving Forward

GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876

Michael Hare
 
Old July 27th, 2009, 03:19 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

I think hex characters are referred to as "&#xE2" etc. Try that see if it works.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old July 27th, 2009, 03:43 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 109
Thanks: 18
Thanked 0 Times in 0 Posts
Default

Sounds logical, but doesn't seem to work.

My expression became: <xsl:analyze-string select="." regex="^([A-Z0-9]+)&#xE2;.*$">, but I'm still not getting a hit.

I did notice that the expression \xnn where nn is a hex value is strictly disallowed by the definition and the interpreter should reject the use of such a construct.

Too bad, \xE2 is just what I was looking for.

Appreciate the effort though.
__________________
------------------------
Keep Moving Forward

GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876

Michael Hare
 
Old July 27th, 2009, 04:23 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Could you show a sample of your XML?

I'm confused as to whether it contains something like

Code:
<element>E2</element>
or something like

Code:
<element>&#xE2;</element>
In the first case the regex to match it is 'E2', in the second case it is '&#xE2;'
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old July 27th, 2009, 04:37 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 109
Thanks: 18
Thanked 0 Times in 0 Posts
Default

Here's the XML:

Code:
<Syntax>SET‑ATTR‑EQPT:[&lt;TID>]:&lt;AID>:&lt;CTAG>::[&lt;NTFCNCDE>],&lt;CONDTYPE>,[&lt;LOCN>],[&lt;DIRN>],,[&lt;SRVEFF>];</Syntax>
In this example, the dashes between SET and ATTR and between ATTR and EQPT are not real dashes (0x2D), but are a secret code embedded when Adobe Framemaker exported an Escaped-Hyphen-H character sequence into XML. ESC-Hyphen-H is something Framemaker uses to create hyphens that don't cause line wraps. In a long line, Framemaker will attempt to line wrap at a dash if one exists in the line. So people use ESC-Hyphen-H to inform Framemaker to wrap at the 80th character, not arbitrily at a dash. The secret code is 0xE2 0x80 0x91, at least that what my hex editor shows the file to contain.

Thanks,

- mike
__________________
------------------------
Keep Moving Forward

GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876

Michael Hare

Last edited by mphare; July 27th, 2009 at 04:39 PM..
 
Old July 27th, 2009, 04:53 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I suspect your hex editor is showing you the UTF-8 encoding of the Unicode character. I suspect the real Unicode character is a non-breaking-hyphen, code x2011 - I haven't actually checked that E28091 is the UTF-8 encoding of x2011, but I suspect it is. If that's the case then the regex you need is '&#x2011;'
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
mphare (July 27th, 2009)
 
Old July 27th, 2009, 05:03 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 109
Thanks: 18
Thanked 0 Times in 0 Posts
Default

That was it. &#x2011; works as expected.

Thank you!
__________________
------------------------
Keep Moving Forward

GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876

Michael Hare





Similar Threads
Thread Thread Starter Forum Replies Last Post
Build Specific Settings? chrislepingwell Visual Studio 2005 2 August 24th, 2007 06:36 AM
Copy specific data in specific cells of sheet2 yogeshyl Excel VBA 1 May 14th, 2007 07:40 AM
Regex with Special Characters [email protected] VB How-To 4 December 15th, 2006 03:16 PM
Find and Replace 2 characters at once!! HELP scovitch65 VB.NET 2002/2003 Basics 2 March 18th, 2006 01:40 AM
JSP string find characters ndanger J2EE 2 November 24th, 2004 09:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.