You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by na...@apache.org on 2006/06/02 07:31:51 UTC

svn commit: r411049 - in /webservices/axis2/trunk/c: util/include/ util/src/ xml_schema/include/xml_schema/ xml_schema/src/

Author: nandika
Date: Thu Jun  1 22:31:51 2006
New Revision: 411049

URL: http://svn.apache.org/viewvc?rev=411049&view=rev
Log:
uri resolver added to xml_schema c

Added:
    webservices/axis2/trunk/c/xml_schema/include/xml_schema/axis2_xml_schema_url_resolver.h
    webservices/axis2/trunk/c/xml_schema/src/xml_schema_url_resolver.c
Modified:
    webservices/axis2/trunk/c/util/include/axis2_string.h
    webservices/axis2/trunk/c/util/src/string.c
    webservices/axis2/trunk/c/xml_schema/include/xml_schema/axis2_xml_schema_includes.h
    webservices/axis2/trunk/c/xml_schema/src/xml_schema_builder.c

Modified: webservices/axis2/trunk/c/util/include/axis2_string.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/include/axis2_string.h?rev=411049&r1=411048&r2=411049&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/include/axis2_string.h (original)
+++ webservices/axis2/trunk/c/util/include/axis2_string.h Thu Jun  1 22:31:51 2006
@@ -69,6 +69,13 @@
     AXIS2_EXTERN axis2_char_t * AXIS2_CALL
     axis2_rindex(const axis2_char_t *s, 
                  axis2_char_t c);
+                 
+    AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+    axis2_replace(axis2_env_t *env,
+                  axis2_char_t *str,
+                  int s1,
+                  int s2);
+                                   
 
 #define AXIS2_STRDUP(pts, env) \
         axis2_strdup(pts, env)
@@ -93,6 +100,9 @@
         
 #define AXIS2_RINDEX(s, c) \
         axis2_rindex(s, c)
+        
+#define AXIS2_REPLACE(env, str, s1, s2) \
+        axis2_replace(env, str, s1, s2)        
 
 /** @} */
     

Modified: webservices/axis2/trunk/c/util/src/string.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/string.c?rev=411049&r1=411048&r2=411049&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/string.c (original)
+++ webservices/axis2/trunk/c/util/src/string.c Thu Jun  1 22:31:51 2006
@@ -129,3 +129,25 @@
         }
         return NULL;
 }
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+axis2_replace(axis2_env_t *env,
+                axis2_char_t *str,
+                int s1,
+                int s2)
+{
+    axis2_char_t *newstr = NULL;
+    axis2_char_t *index = NULL;
+    if(!str)
+        return NULL;
+    
+    newstr = AXIS2_STRDUP(str, env);
+    
+    index = strchr(newstr, s1);
+    while(NULL != index)
+    {
+        newstr[index - newstr] = s2;
+        index = strchr(newstr, s1);
+    }
+    return newstr;
+}                
\ No newline at end of file

Modified: webservices/axis2/trunk/c/xml_schema/include/xml_schema/axis2_xml_schema_includes.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/xml_schema/include/xml_schema/axis2_xml_schema_includes.h?rev=411049&r1=411048&r2=411049&view=diff
==============================================================================
--- webservices/axis2/trunk/c/xml_schema/include/xml_schema/axis2_xml_schema_includes.h (original)
+++ webservices/axis2/trunk/c/xml_schema/include/xml_schema/axis2_xml_schema_includes.h Thu Jun  1 22:31:51 2006
@@ -72,6 +72,7 @@
 #include "axis2_xml_schema.h"
 #include "axis2_xml_schema_redefine.h"
 #include "axis2_xml_schema_type.h"
+#include "axis2_xml_schema_url_resolver.h"
 
 #ifdef _cplusplus
 extern "C"

Added: webservices/axis2/trunk/c/xml_schema/include/xml_schema/axis2_xml_schema_url_resolver.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/xml_schema/include/xml_schema/axis2_xml_schema_url_resolver.h?rev=411049&view=auto
==============================================================================
--- webservices/axis2/trunk/c/xml_schema/include/xml_schema/axis2_xml_schema_url_resolver.h (added)
+++ webservices/axis2/trunk/c/xml_schema/include/xml_schema/axis2_xml_schema_url_resolver.h Thu Jun  1 22:31:51 2006
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AXIS2_XML_SCHEMA_URL_RESOLVER_H
+#define AXIS2_XML_SCHEMA_URL_RESOLVER_H
+
+/**
+ * @file axis2_xml_schema_url_resolver.h
+ */
+#include <axis2_url.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+axis2_xml_schema_url_resolver_resolve_entity(
+        axis2_env_t *env,
+        axis2_char_t *ns,
+        axis2_char_t *schema_location,
+        axis2_char_t *base_uri);
+        
+/** @} */
+#ifdef __cplusplus
+}
+#endif
+#endif /* AXIS2_XML_SCHEMA_IMPORT_H */

Modified: webservices/axis2/trunk/c/xml_schema/src/xml_schema_builder.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/xml_schema/src/xml_schema_builder.c?rev=411049&r1=411048&r2=411049&view=diff
==============================================================================
--- webservices/axis2/trunk/c/xml_schema/src/xml_schema_builder.c (original)
+++ webservices/axis2/trunk/c/xml_schema/src/xml_schema_builder.c Thu Jun  1 22:31:51 2006
@@ -3945,5 +3945,24 @@
         axis2_char_t *schema_location,
         axis2_char_t *base_uri)
 {
+    axis2_xml_reader_t *xml_reader = NULL;
+    axis2_om_document_t *om_doc = NULL;
+    axis2_om_stax_builder_t *om_builder = NULL;
+    axis2_xml_schema_collection_t *collection = NULL;
+    axis2_xml_schema_builder_t *builder = NULL;
+    axis2_char_t *filename = NULL;
+    filename = axis2_xml_schema_url_resolver_resolve_entity(env, 
+        target_namespace, schema_location, base_uri);
+    xml_reader = axis2_xml_reader_create_for_file(env, filename, NULL);
+    if(!xml_reader)
+        return NULL;        
+    om_builder = axis2_om_stax_builder_create(env, xml_reader);
+    if(!om_builder)
+        return NULL;
+    om_doc = axis2_om_document_create(env, NULL, om_builder);
+    AXIS2_OM_DOCUMENT_BUILD_ALL(om_doc, env);
+    collection = axis2_xml_schema_collection_create(env);
+    return AXIS2_XML_SCHEMA_COLLECTION_READ_DOCUMENT_WITH_URI(collection, env, om_doc, base_uri);        
+            
     return NULL;
-}            
\ No newline at end of file
+}            

Added: webservices/axis2/trunk/c/xml_schema/src/xml_schema_url_resolver.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/xml_schema/src/xml_schema_url_resolver.c?rev=411049&view=auto
==============================================================================
--- webservices/axis2/trunk/c/xml_schema/src/xml_schema_url_resolver.c (added)
+++ webservices/axis2/trunk/c/xml_schema/src/xml_schema_url_resolver.c Thu Jun  1 22:31:51 2006
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <xml_schema/axis2_xml_schema_url_resolver.h>
+#include <axis2_url.h>
+#include <axis2_file_handler.h>
+#include <platforms/axis2_platform_auto_sense.h>
+
+#ifndef S_ISDIR
+#   define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
+#endif
+
+
+static axis2_bool_t 
+is_absolute_url(const axis2_char_t *url);
+
+static axis2_char_t*
+get_url(axis2_env_t *env,
+        axis2_char_t *path,
+        axis2_char_t *spec);
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+axis2_xml_schema_url_resolver_resolve_entity(
+        axis2_env_t *env,
+        axis2_char_t *ns,
+        axis2_char_t *schema_location,
+        axis2_char_t *base_uri)
+{
+    if(!base_uri)
+        return schema_location;
+        
+    if(!is_absolute_url(schema_location))
+    {
+        axis2_char_t *path = NULL;
+        path = get_url(env, base_uri, schema_location);        
+        return path;
+    }
+    return schema_location;
+}        
+
+static axis2_bool_t 
+is_absolute_url(const axis2_char_t *url)
+{
+    if(NULL != url)
+    {
+        if(strncmp(url, "http://", 7) == 0)
+            return AXIS2_TRUE;
+    }
+    return AXIS2_FALSE;
+}
+
+static axis2_char_t*
+get_url(axis2_env_t *env,
+        axis2_char_t *path,
+        axis2_char_t *spec)
+{
+    axis2_char_t *modified_path = NULL;
+    axis2_url_t *url = NULL;
+    axis2_char_t *final_path = NULL;
+    int length = 0; 
+       
+    if(NULL != path)
+    {
+        modified_path = AXIS2_STRDUP(spec, env);
+    }
+    /** create a path */
+    modified_path = AXIS2_REPLACE(env, modified_path, '\\','/');
+    
+    if(strncmp(modified_path, "/", 1) == 0)
+    {
+        final_path = AXIS2_STRACAT(path, modified_path, env);
+    }
+    else
+    {
+        axis2_char_t *temp_path = NULL;
+        temp_path = AXIS2_STRACAT(path, "/",env);
+        final_path = AXIS2_STRACAT(temp_path, modified_path, env);
+        AXIS2_FREE(env->allocator, modified_path);
+    }
+        
+    if(NULL != final_path)
+    {       
+        if(strncmp(final_path,"file:///", 8) == 0)
+        {
+            axis2_char_t *real_path = NULL;
+            axis2_char_t *start = NULL;
+            start = final_path+8*sizeof(axis2_char_t);
+            real_path = AXIS2_STRDUP(start, env);
+            AXIS2_FREE(env->allocator, final_path);
+            if(axis2_file_handler_access(real_path, AXIS2_F_OK))
+                return real_path;
+        } 
+        else
+            if(axis2_file_handler_access(final_path, AXIS2_F_OK))
+                return final_path;
+    }
+    return NULL;
+}        



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org