Humboldt Alignment Editor 2.5.0

eu.esdihumboldt.hale.common.core.io.project.util
Class XMLSchemaUpdater

java.lang.Object
  extended by eu.esdihumboldt.hale.common.core.io.project.util.XMLSchemaUpdater

public class XMLSchemaUpdater
extends Object

Class for updating XML schemas in the ArchiveProjectWriter.
Resolves the imported/included xml schemas, copies them next to the given schema (or a subdirectory) and adapts the import/include location in the schema.

Author:
Patrick Lieb

Constructor Summary
XMLSchemaUpdater()
           
 
Method Summary
static void update(File resource, URI oldFile, boolean includeWebResources, IOReporter reporter)
          Reads the given xml schema (resource) and searches for included and imported schemas in the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLSchemaUpdater

public XMLSchemaUpdater()
Method Detail

update

public static void update(File resource,
                          URI oldFile,
                          boolean includeWebResources,
                          IOReporter reporter)
                   throws IOException
Reads the given xml schema (resource) and searches for included and imported schemas in the file. If these files are local, the function tries to copy the resources into a new directory next to the given schema (resource) and adapts the dependencies in the resource. The oldFile is the path of the xml schema before it was copied to his new directory (eg. temporary directory). The oldFile keeps untouched. Resource has to be a copy of oldFile.

Example:
resource file is 'C:/Local/Temp/1348138164029-0/watercourse/wfs_va.xsd'
oldFile is 'C:/igd/hale/watercourse/wfs_va.xsd'.
wfs_va.xsd has one schema import with location 'C:/igd/hale/watercourse/schemas/hydro.xsd'
So hydro.xsd is copied into 'C:/Local/Temp/1348138164029-0/watercourse/' (or a subdirectory) and the import location in wfs_va.xsd will be adapted.
Resources only will be copied once. In this case the schema location is solved relative to the originally schema.

Parameters:
resource - the file of the new resource (will be adapted)
oldFile - the file of the old resource (will be untouched)
includeWebResources - true if web resources should be copied and updated too otherwise false
reporter - the reporter of the current I/O process where errors should be reported to
Throws:
IOException - if file can not be updated

Humboldt Alignment Editor 2.5.0

Build 2012-12-03_12-30-59
Revision 9d2dd4b0318cda9f1393b1ddd390f7f792d70a2d