xsddoc/src/net/sf/xframe/xsddoc Task.java,1.23,1.24

Kurt Riede <[email protected]> Fri, 30 Sep 2005 18:28:42 +0000
Newsgroups gmane.text.xml.xframe.xsddoc.devel
Message-ID <[email protected]>
Update of /cvsroot/xframe/xsddoc/src/net/sf/xframe/xsddoc
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30228/src/net/sf/xframe/xsddoc

Modified Files:
	Task.java 
Log Message:
fixes for the following bugs:
[1228808] Question about ant task when using FileSets
[1307377] Correction for Task.java to address FileSet issues

Index: Task.java
===================================================================
RCS file: /cvsroot/xframe/xsddoc/src/net/sf/xframe/xsddoc/Task.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** Task.java	30 Sep 2005 17:54:12 -0000	1.23
--- Task.java	30 Sep 2005 18:28:40 -0000	1.24
***************
*** 230,235 ****
          }
          if (filesets.size() > 0) {
!             builder = getDocumentBuilder();
!             final Document mediatorSchema = builder.getDOMImplementation().createDocument(SCHEMA_NS, "schema", null);
              for (int i = 0; i < filesets.size(); i++) {
                  final FileSet fileSet = (FileSet) filesets.elementAt(i);
--- 230,234 ----
          }
          if (filesets.size() > 0) {
!             final Document mediatorSchema = createDocument();
              for (int i = 0; i < filesets.size(); i++) {
                  final FileSet fileSet = (FileSet) filesets.elementAt(i);
***************
*** 237,241 ****
                  addSchemas(mediatorSchema, scanner.getBasedir().getAbsolutePath(), scanner);
              }
!             processor.setSchemaLocation(getProject().getBaseDir().getAbsolutePath() + File.separator + "todo");
              processor.setMainSchema(mediatorSchema);
              processor.execute();
--- 236,240 ----
                  addSchemas(mediatorSchema, scanner.getBasedir().getAbsolutePath(), scanner);
              }
!             processor.setSchemaLocation(getProject().getBaseDir().getAbsolutePath() + File.separator + "mediator-schema");
              processor.setMainSchema(mediatorSchema);
              processor.execute();
***************
*** 301,307 ****
       */
      private void addSchema(final Document mediatorSchema, final String base, final String schemaLocation) {
!         String targetNamespace = null;
!         targetNamespace = getTargetNamespace(base, schemaLocation);
!         if (targetNamespace == null) {
              if (debug) {
                  System.out.println("Seems not to be a schema, ignoring " + schemaLocation);
--- 300,306 ----
       */
      private void addSchema(final Document mediatorSchema, final String base, final String schemaLocation) {
!         String namespace = null;
!         namespace = getNamespace(base, schemaLocation);
!         if (namespace == null) {
              if (debug) {
                  System.out.println("Seems not to be a schema, ignoring " + schemaLocation);
***************
*** 313,332 ****
          }
          final Element importNode = mediatorSchema.createElementNS(SCHEMA_NS, "import");
!         final String projectDir = getProject().getBaseDir().getAbsolutePath() + File.separator;
!         // Since the processor interprets everything as relative, the schemaLocation should
!         // be the relative path from the project base. However the base string may contain
!         // some path info not in the base. That is the base may be obtained from the fileset
!         // attribute.
!         final String schemaLoc;
!         //Does the base have additional information?
!         // TODO check the following against mail from Gianluca Chiozzi
!         if (base.length() > projectDir.length() && base.startsWith(projectDir)) {
!             String relativePath = base.substring(projectDir.length());
!             schemaLoc = relativePath + File.separator + schemaLocation;
!         } else {
!             schemaLoc = schemaLocation;
!         }
          importNode.setAttribute("schemaLocation", schemaLoc);
!         importNode.setAttribute("namespace", targetNamespace);
          mediatorSchema.getDocumentElement().appendChild(importNode);
      }
--- 312,318 ----
          }
          final Element importNode = mediatorSchema.createElementNS(SCHEMA_NS, "import");
!         final String schemaLoc = (new File(base, schemaLocation)).getAbsolutePath();
          importNode.setAttribute("schemaLocation", schemaLoc);
!         importNode.setAttribute("namespace", namespace);
          mediatorSchema.getDocumentElement().appendChild(importNode);
      }
***************
*** 342,351 ****
       * @return target namespace of schema or <tt>null</tt> if the document is not a schema
       */
!     private String getTargetNamespace(final String base, final String filename) {
          try {
              final Document schema = getDocumentBuilder().parse(new File(base, filename));
              final Element root = schema.getDocumentElement();
              return root.getAttribute("targetNamespace");
          } catch (Exception e) {
              return null;
          }
--- 328,341 ----
       * @return target namespace of schema or <tt>null</tt> if the document is not a schema
       */
!     private String getNamespace(final String base, final String filename) {
          try {
              final Document schema = getDocumentBuilder().parse(new File(base, filename));
              final Element root = schema.getDocumentElement();
+             if (!root.getLocalName().equals("schema") || !root.getNamespaceURI().equals(Task.SCHEMA_NS)) {
+                 return null;
+             }
              return root.getAttribute("targetNamespace");
          } catch (Exception e) {
+             e.printStackTrace();
              return null;
          }



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl