ComposableBody.BOSH_START

  4 posts   Feedicon  
Replies: 3 - Last Post: May 18, 2011 20:03
by: Mike Cumings
showing 1 - 4 of 4
 
Posted: May 11, 2011 02:03 by gmaynard
(The site finally let me create an account...)

While reviewing someone else's patch (for running on Android), I was trying to parse out the regex here:

private static final Pattern BOSH_START =
Pattern.compile("<" + "(?Frown?:[^:\t\n\r >]+Smile|(?:\\{[^\\}>]*?}))?"
+ "body" + "(?:[\t\n\r ][^>]*?)?" + "(/>|>)");

The part I'm not following is:
(?:\\{[^\\}>]*?})

This causes it to match <\{text}body>. I wondered if it was some obscure XML syntax that I hadn't seen, but it doesn't look like it. Remember what that bit is for?
 
Posted: May 11, 2011 02:03 by gmaynard
GAAAH.

    private static final Pattern BOSH_START =
            Pattern.compile("<" + "(?:(?:[^:\t\n\r >]+:)|(?:\\{[^\\}>]*?}))?"
            + "body" + "(?:[\t\n\r ][^>]*?)?" + "(/>|>)");



 
Posted: May 18, 2011 20:03 by Mike Cumings
I can't recall why that particular subexpression was used. I think I may have pulled it in thinking that the local XSI type specification format used in schemas was part of the XML namespace spec. Reading through the namespace spec, this is obviously not the case. I've yanked the subexpression in question from the code in trunk and have also escaped the final closing brace.

As an aside, the regex-based parsing is currently only used within the tests. I'll probably be pulling it out into a test lib sometime in the future to clean this up further.

Thanks for the feedback!

 
Posted: May 13, 2011 20:42 by gmaynard
FYI, to make this expression compile on the Pattern package Android uses, the final } must be escaped:

-            Pattern.compile("<" + "(?:(?:[^:\t\n\r >]+:)|(?:\\{[^\\}>]*?}))?"
+            Pattern.compile("<" + "(?:(?:[^:\t\n\r >]+:)|(?:\\{[^\\}>]*?\\}))?"


I'd still like to know what that subgroup is for...
Replies: 3 - Last Post: May 18, 2011 20:03
by: Mike Cumings
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close