geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
Subject svn commit: r209098 - /geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
Date Mon, 04 Jul 2005 16:28:53 GMT
Author: ammulder
Date: Mon Jul  4 09:28:50 2005
New Revision: 209098

URL: http://svn.apache.org/viewcvs?rev=209098&view=rev
Log:
Add a helper to get a nested child element without changing its type

Modified:
    geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java

Modified: geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java?rev=209098&r1=209097&r2=209098&view=diff
==============================================================================
--- geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
(original)
+++ geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
Mon Jul  4 09:28:50 2005
@@ -408,6 +408,26 @@
         return xmlObject;
     }
 
+    public static XmlObject getNestedObject(XmlObject xmlObject, String desiredElement) {
+        XmlCursor cursor = xmlObject.newCursor();
+        try {
+            while (cursor.hasNextToken()) {
+                if (cursor.isStart()) {
+                    String localName = cursor.getName().getLocalPart();
+                    if (localName.equals(desiredElement)) {
+                        XmlObject child = cursor.getObject();
+                        //The copy seems to be needed to make the type change work for some
documents!
+                        return child.copy();
+                    }
+                }
+                cursor.toNextToken();
+            }
+        } finally {
+            cursor.dispose();
+        }
+        throw new IllegalArgumentException("xmlobject did not have desired element: " + desiredElement
+ "/n" + xmlObject);
+    }
+
     public static XmlObject getNestedObjectAsType(XmlObject xmlObject, String desiredElement,
SchemaType type) {
         XmlCursor cursor = xmlObject.newCursor();
         try {



Mime
View raw message