camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [5/5] git commit: CAMEL-6607 fixed the issue that Tokenize XML does not support child elements with names similar to their parent
Date Tue, 06 Aug 2013 12:17:02 GMT
CAMEL-6607 fixed the issue that Tokenize XML does not support child elements with names similar
to their parent


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ab76a81a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ab76a81a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ab76a81a

Branch: refs/heads/camel-2.10.x
Commit: ab76a81ada3123e2378563fb183fdb7543cbb1f9
Parents: 5404458
Author: Willem Jiang <ningjiang@apache.org>
Authored: Tue Aug 6 17:36:02 2013 +0800
Committer: Willem Jiang <ningjiang@apache.org>
Committed: Tue Aug 6 19:25:34 2013 +0800

----------------------------------------------------------------------
 .../org/apache/camel/support/TokenXMLExpressionIterator.java | 4 ++--
 .../test/java/org/apache/camel/language/TokenizerTest.java   | 8 ++++++++
 2 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ab76a81a/camel-core/src/main/java/org/apache/camel/support/TokenXMLExpressionIterator.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/support/TokenXMLExpressionIterator.java
b/camel-core/src/main/java/org/apache/camel/support/TokenXMLExpressionIterator.java
index b8d4374..938b1d6 100644
--- a/camel-core/src/main/java/org/apache/camel/support/TokenXMLExpressionIterator.java
+++ b/camel-core/src/main/java/org/apache/camel/support/TokenXMLExpressionIterator.java
@@ -47,7 +47,7 @@ import org.apache.camel.util.ObjectHelper;
 public class TokenXMLExpressionIterator extends ExpressionAdapter {
     private static final Pattern NAMESPACE_PATTERN = Pattern.compile("xmlns(:\\w+|)\\s*=\\s*('[^']+'|\"[^\"]+\")");
     private static final String SCAN_TOKEN_NS_PREFIX_REGEX = "([^:<>]{1,15}?:|)";
-    private static final String SCAN_BLOCK_TOKEN_REGEX_TEMPLATE = "<{0}(\\s+[^/]*)?/>|<{0}(\\s+[^>]*)?>(?:(?!</{0}).)*</{0}\\s*>";
+    private static final String SCAN_BLOCK_TOKEN_REGEX_TEMPLATE = "<{0}(\\s+[^/]*)?/>|<{0}(\\s+[^>]*)?>(?:(?!(</{0}\\s*>)).)*</{0}\\s*>";
     private static final String SCAN_PARENT_TOKEN_REGEX_TEMPLATE = "<{0}(\\s+[^>]*\\s*)?>";
     
     protected final String tagToken;
@@ -133,7 +133,7 @@ public class TokenXMLExpressionIterator extends ExpressionAdapter {
             this.tagToken = tagToken;
             this.in = in;
             this.charset = charset;
-
+          
             // remove any beginning < and ending > as we need to support ns prefixes
and attributes, so we use a reg exp patterns
             this.tagTokenPattern = 
                 Pattern.compile(MessageFormat.format(SCAN_BLOCK_TOKEN_REGEX_TEMPLATE, 

http://git-wip-us.apache.org/repos/asf/camel/blob/ab76a81a/camel-core/src/test/java/org/apache/camel/language/TokenizerTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/language/TokenizerTest.java b/camel-core/src/test/java/org/apache/camel/language/TokenizerTest.java
index 7414583..414b926 100644
--- a/camel-core/src/test/java/org/apache/camel/language/TokenizerTest.java
+++ b/camel-core/src/test/java/org/apache/camel/language/TokenizerTest.java
@@ -204,6 +204,14 @@ public class TokenizerTest extends ExchangeTestSupport {
         List<?> names = exp.evaluate(exchange, List.class);
         assertNull(names);
     }
+    
+    public void testTokenizeXMLPairWithSimilarChildNames() throws Exception {
+        Expression exp = TokenizeLanguage.tokenizeXML("Trip", "Trips");
+        exchange.getIn().setBody("<?xml version='1.0' encoding='UTF-8'?>\n<Trips>\n<Trip>\n<TripType>\n</TripType>\n</Trip>\n</Trips>");
+        List<?> names = exp.evaluate(exchange, List.class);
+        assertEquals(1, names.size());
+    }
+    
 
     public void testTokenizeXMLPairWithDefaultNamespace() throws Exception {
         Expression exp = TokenizeLanguage.tokenizeXML("<person>", "<persons>");


Mime
View raw message