[Castore-commits] XMLUtils.java 1.1.2.2 1.1.2.3

Stéphane Bouchet sbouchet at adullact1.hosting.cri74.org
Lun 6 Mar 12:14:49 CET 2006


Update of /cvsroot/castore/castore-core/src/java/fr/emn/castor/documents/retro/tools
In directory adullact1:/tmp/cvs-serv11877/src/java/fr/emn/castor/documents/retro/tools

Modified Files:
      Tag: v1_1_branch
	XMLUtils.java 
Log Message:
mise en page

Index: XMLUtils.java
===================================================================
RCS file: /cvsroot/castore/castore-core/src/java/fr/emn/castor/documents/retro/tools/XMLUtils.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** XMLUtils.java	7 Feb 2006 15:46:10 -0000	1.1.2.2
--- XMLUtils.java	6 Mar 2006 11:14:47 -0000	1.1.2.3
***************
*** 56,60 ****
      // Validation feature id (http://xml.org/sax/features/validation).
      protected static final String VALIDATION_FEATURE_ID = "http://xml.org/sax/features/validation";
! 	
      // Schema validation feature id (http://apache.org/xml/features/validation/schema).
      protected static final String SCHEMA_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/schema";
--- 56,60 ----
      // Validation feature id (http://xml.org/sax/features/validation).
      protected static final String VALIDATION_FEATURE_ID = "http://xml.org/sax/features/validation";
! 
      // Schema validation feature id (http://apache.org/xml/features/validation/schema).
      protected static final String SCHEMA_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/schema";
***************
*** 62,74 ****
      // Entity resolver feature id (http://apache.org/xml/properties/internal/entity-resolver).
      protected static final String ENTITY_RESOLVER_FEATURE_ID = "http://apache.org/xml/properties/internal/entity-resolver";
!     
      // Include ignorable whitespace feature id (http://apache.org/xml/features/dom/include-ignorable-whitespace). 
      // Works Only with DOMParser and DTD 
      protected static final String INCLUDE_IGNORABLE_WHITESPACE_FEATURE_ID = "http://apache.org/xml/features/dom/include-ignorable-whitespace";
!       
!     protected static SAXBuilder builder;    
      protected static XMLOutputter serializer;
      protected static boolean init = false;
!     
      //  This method init the parser used later to load XML file into JDom Document
      //				 and the serializer used later to write a JDOM Document into a XML File 
--- 62,76 ----
      // Entity resolver feature id (http://apache.org/xml/properties/internal/entity-resolver).
      protected static final String ENTITY_RESOLVER_FEATURE_ID = "http://apache.org/xml/properties/internal/entity-resolver";
! 
      // Include ignorable whitespace feature id (http://apache.org/xml/features/dom/include-ignorable-whitespace). 
      // Works Only with DOMParser and DTD 
      protected static final String INCLUDE_IGNORABLE_WHITESPACE_FEATURE_ID = "http://apache.org/xml/features/dom/include-ignorable-whitespace";
! 
!     protected static SAXBuilder builder;
! 
      protected static XMLOutputter serializer;
+ 
      protected static boolean init = false;
! 
      //  This method init the parser used later to load XML file into JDom Document
      //				 and the serializer used later to write a JDOM Document into a XML File 
***************
*** 80,106 ****
       * @return void
       */
!     public static void init(String catalog) 
!     {
!     	if (init == false)
!     	{
!     		// Create builder to build JDOM document from XML File
! 	    	builder = new SAXBuilder("com.sun.org.apache.xerces.internal.parsers.SAXParser");
! 	    	// Validate the XML Document against its grammar
! 	    	builder.setValidation(false);
! 	    	// Support Schema grammar
! 	    	builder.setFeature(SCHEMA_VALIDATION_FEATURE_ID, false);
! 	    	// Support OASIS catalog
! 	    	/*
! 	    	CatalogManager catalogManager = new CatalogManager();
! 	    	catalogManager.setCatalogFiles(catalog);
! 	    	CatalogResolver catalogResolver = new CatalogResolver(catalogManager);
! 	    	builder.setProperty(ENTITY_RESOLVER_FEATURE_ID, catalogResolver); */
! 	    	
! 	    	// Create the serializer to create XML file from JDOM Document
! 			serializer = new XMLOutputter();
!     	}   	
!     	init = true;
      }
!     
      //  This method writes a XML document to a file
      /**
--- 82,107 ----
       * @return void
       */
!     public static void init(String catalog) {
!         if (init == false) {
!             // Create builder to build JDOM document from XML File
!             builder = new SAXBuilder(
!                 "com.sun.org.apache.xerces.internal.parsers.SAXParser");
!             // Validate the XML Document against its grammar
!             builder.setValidation(false);
!             // Support Schema grammar
!             builder.setFeature(SCHEMA_VALIDATION_FEATURE_ID, false);
!             // Support OASIS catalog
!             /*
!              CatalogManager catalogManager = new CatalogManager();
!              catalogManager.setCatalogFiles(catalog);
!              CatalogResolver catalogResolver = new CatalogResolver(catalogManager);
!              builder.setProperty(ENTITY_RESOLVER_FEATURE_ID, catalogResolver); */
! 
!             // Create the serializer to create XML file from JDOM Document
!             serializer = new XMLOutputter();
!         }
!         init = true;
      }
! 
      //  This method writes a XML document to a file
      /**
***************
*** 113,130 ****
       * @return void
       */
!     public static void getXMLFileFromDocument(Document document, String outputFilePath) {
!     	try 
!     	{
              //  Create a XML File from a JDOM tree
!             serializer.output(document, new FileOutputStream(outputFilePath));
! 		} catch (FileNotFoundException e) {
! 			// TODO Auto-generated catch block
! 			e.printStackTrace();
! 		} catch (IOException e) {
! 			// TODO Auto-generated catch block
! 			e.printStackTrace();
! 		} 
      }
!     
      //  This method load a XML file into a XML document
      /**
--- 114,135 ----
       * @return void
       */
!     public static void getXMLFileFromDocument(
!             Document document, String outputFilePath) {
!         FileOutputStream outStream = null;
!         try {
              //  Create a XML File from a JDOM tree
!             outStream = new FileOutputStream(outputFilePath);
!             serializer.output(document, outStream);
!             outStream.close();
!         } catch (FileNotFoundException e) {
!             // TODO Auto-generated catch block
!             e.printStackTrace();
!         } catch (IOException e) {
!             // TODO Auto-generated catch block
!             e.printStackTrace();
!         }
! 
      }
! 
      //  This method load a XML file into a XML document
      /**
***************
*** 135,165 ****
       * @return the output XML Document
       */
!     public static Document getDocumentFromXMLFile(String inputFilePath) 
!     {
!     	
!     	Document doc = null;
!     	
!     	try {
!     		doc = builder.build(inputFilePath);
! 		} 
!     	catch (IOException e) 
! 		{
! 			// TODO Auto-generated catch block
! 			e.printStackTrace();
! 		} 
!     	catch (JDOMException e) 
!     	{
! 			// TODO Auto-generated catch block
! 			e.printStackTrace();
! 		}
! 		return doc;
!     }    
! /*    private static final String ERROR_IO = "Erreur d'entrée/sortie lors de l'appel à construteur.parse(xml)";
  
!     private static final String ERROR_UNKNOWN = "Unknown error";
  
!     private static final String ERROR_TRANSFORMER_FACTORY = "Transformer Factory error";
  
!     private static final String ERROR_TRANSFORMATION = "Transformation error";*/
  
  }
--- 140,165 ----
       * @return the output XML Document
       */
!     public static Document getDocumentFromXMLFile(String inputFilePath) {
  
!         Document doc = null;
  
!         try {
!             doc = builder.build(inputFilePath);
!         } catch (IOException e) {
!             // TODO Auto-generated catch block
!             e.printStackTrace();
!         } catch (JDOMException e) {
!             // TODO Auto-generated catch block
!             e.printStackTrace();
!         }
!         return doc;
!     }
!     /*    private static final String ERROR_IO = "Erreur d'entrée/sortie lors de l'appel à construteur.parse(xml)";
  
!      private static final String ERROR_UNKNOWN = "Unknown error";
! 
!      private static final String ERROR_TRANSFORMER_FACTORY = "Transformer Factory error";
! 
!      private static final String ERROR_TRANSFORMATION = "Transformation error";*/
  
  }




Plus d'informations sur la liste de diffusion Castore-commits