[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jibx-cvs
Subject:    [Jibx-cvs] core/build/src/org/jibx/schema SchemaHolder.java, 1.2,
From:       Dennis Sosnoski <dsosnoski () users ! sourceforge ! net>
Date:       2010-01-20 11:15:29
Message-ID: E1NXYX3-0002yP-Im () sfp-cvsdas-3 ! v30 ! ch3 ! sourceforge ! com
[Download RAW message or body]

Update of /cvsroot/jibx/core/build/src/org/jibx/schema
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv11423/build/src/org/jibx/schema


Modified Files:
	SchemaHolder.java 
Log Message:
Support use with existing files; handle referenced schemas using same namespace or no \
namespace with <include>.

Index: SchemaHolder.java
===================================================================
RCS file: /cvsroot/jibx/core/build/src/org/jibx/schema/SchemaHolder.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SchemaHolder.java	10 Sep 2008 11:57:01 -0000	1.2
--- SchemaHolder.java	20 Jan 2010 11:15:27 -0000	1.3
***************
*** 1,4 ****
  /*
!  * Copyright (c) 2007-2008, Dennis M. Sosnoski All rights reserved.
   * 
   * Redistribution and use in source and binary forms, with or without modification, \
                are permitted provided that the
--- 1,4 ----
  /*
!  * Copyright (c) 2007-2010, Dennis M. Sosnoski. All rights reserved.
   * 
   * Redistribution and use in source and binary forms, with or without modification, \
                are permitted provided that the
***************
*** 28,31 ****
--- 28,32 ----
  import org.jibx.schema.attributes.FormChoiceAttribute;
  import org.jibx.schema.elements.ImportElement;
+ import org.jibx.schema.elements.IncludeElement;
  import org.jibx.schema.elements.SchemaElement;
  import org.jibx.util.HolderBase;
***************
*** 43,52 ****
      private final SchemaElement m_schema;
      
!     /** Set of type names defined in schema. */
      private final UniqueNameSet m_typeNameSet;
      
!     /**
!      * Set of element names defined in schema (also used for group/attributeGroup).
!      */
      private final UniqueNameSet m_elementNameSet;
      
--- 44,51 ----
      private final SchemaElement m_schema;
      
!     /** Set of type names defined in schema (only for new schema definitions). */
      private final UniqueNameSet m_typeNameSet;
      
!     /** Set of element names defined in schema (also used for group/attributeGroup; \
only for new definitions). */  private final UniqueNameSet m_elementNameSet;
      
***************
*** 55,59 ****
      
      /**
!      * Constructor.
       * 
       * @param uri (<code>null</code> if no-namespace schema)
--- 54,58 ----
      
      /**
!      * Constructor for new schema definition file.
       * 
       * @param uri (<code>null</code> if no-namespace schema)
***************
*** 72,75 ****
--- 71,85 ----
      
      /**
+      * Constructor for existing schema definition file.
+      * 
+      * @param schema schema definition
+      */
+     public SchemaHolder(SchemaElement schema) {
+         super(schema.getTargetNamespace(), schema.getResolver().getName());
+         m_schema = schema;
+         m_typeNameSet = m_elementNameSet = null;
+     }
+     
+     /**
       * Get the schema definition.
       * 
***************
*** 88,91 ****
--- 98,104 ----
       */
      public String addTypeName(String base) {
+         if (!isModifiable()) {
+             throw new IllegalStateException("Internal error - file is not \
modifiable"); +         }
          return m_typeNameSet.add(base);
      }
***************
*** 101,104 ****
--- 114,120 ----
       */
      public String addElementName(String base) {
+         if (!isModifiable()) {
+             throw new IllegalStateException("Internal error - file is not \
modifiable"); +         }
          return m_elementNameSet.add(base);
      }
***************
*** 120,123 ****
--- 136,142 ----
       */
      public void finish() {
+         if (!isModifiable()) {
+             throw new IllegalStateException("Internal error - file is not \
modifiable"); +         }
          if (m_fixedSet == null) {
              m_fixedSet = new HashSet();
***************
*** 127,138 ****
              if (!m_fixedSet.contains(holder)) {
                  String ns = holder.getNamespace();
!                 ImportElement imp = new ImportElement();
!                 imp.setLocation(holder.getFileName());
!                 imp.setNamespace(ns);
!                 m_schema.getSchemaChildren().add(imp);
!                 getPrefix(ns);
                  m_fixedSet.add(holder);
              }
          }
      }
  }
\ No newline at end of file
--- 146,167 ----
              if (!m_fixedSet.contains(holder)) {
                  String ns = holder.getNamespace();
!                 String file = holder.getFileName();
!                 if (ns == null || ns.equals(getNamespace())) {
!                     if (file != null) {
!                         IncludeElement inc = new IncludeElement();
!                         inc.setLocation(file);
!                         m_schema.getSchemaChildren().add(inc);
!                     }
!                 } else {
!                     ImportElement imp = new ImportElement();
!                     imp.setLocation(file);
!                     imp.setNamespace(ns);
!                     m_schema.getSchemaChildren().add(imp);
!                     getPrefix(ns);
!                 }
                  m_fixedSet.add(holder);
              }
          }
+         super.finish();
      }
  }
\ No newline at end of file


------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Jibx-cvs mailing list
Jibx-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic