4,10 → 4,10 |
* Coded by: Group 5, software practice summer 2003 |
* University of Bielefeld, Germany |
* |
* @version $Revision: 1.68 $ |
* @version $Revision: 1.69 $ |
* |
* Last modification: $Date: 2003/07/26 13:05:50 $ |
* $Id: OurDocument.java,v 1.68 2003/07/26 13:05:50 smcsporr Exp $ |
* Last modification: $Date: 2003/07/26 13:23:58 $ |
* $Id: OurDocument.java,v 1.69 2003/07/26 13:23:58 smcsporr Exp $ |
*/ |
|
package src.document; |
44,7 → 44,7 |
* |
* @author S. McSporran |
* |
* @version $Revision: 1.68 $ Last modification: $Date: 2003/07/26 13:05:50 $ |
* @version $Revision: 1.69 $ Last modification: $Date: 2003/07/26 13:23:58 $ |
*/ |
public class OurDocument { |
|
248,7 → 248,7 |
* |
* It parses the XML schema file and retrieves it's 'targetNamespace' attribute |
* first to get the schema locations namespace. If no target namespace is |
* specified, the default namespace declared in the XML document will be used. |
* specified, a default namespace will be used. |
* |
* @param changeDoc The document who's associated schema should be changed. |
* @param dtdFile The new schema's path and filename as <code>File</code>-object. |
261,6 → 261,8 |
*/ |
public void changeSchemaGrammar(DocumentImpl changeDoc, File schemaFile) { |
|
final String defaultNS = "http://www.w3.org/2001/XMLSchema-instance"; |
|
/* Create an empty DOM document used as data container. */ |
DocumentImpl tempDocument = new DocumentImpl(); |
|
270,7 → 272,7 |
Element rootElement = changeDoc.getDocumentElement(); |
rootElement.removeAttribute("xsi:schemaLocation"); |
myDocument = changeDoc; |
log(LogInterface.TYPE_INFO, "Schema removed"); |
log(LogInterface.TYPE_INFO, "Schema entry removed"); |
|
} else { |
|
282,7 → 284,7 |
tempDocument = aParser.getDocument(); |
Element schemaRootElement = tempDocument.getDocumentElement(); |
|
/* Try to get the 'targetNamespace' attribute. */ |
/* Try to get the 'targetNamespace' attribute from the schema file. */ |
String targetNamespaceAttribute = schemaRootElement.getAttribute("targetNamespace"); |
|
if (! targetNamespaceAttribute.equals("")) { |
291,6 → 293,10 |
XMLRootElement.setAttribute("xsi:schemaLocation", targetNamespaceAttribute + " " + |
schemaFile.getPath()); |
} else { |
|
/* Set a default schemaLocation attribute when no targetNamespace was available. */ |
XMLRootElement.setAttribute("xsi:schemaLocation", defaultNS + " " + |
schemaFile.getPath()); |
} |
} |
|
410,6 → 416,10 |
if (((saveDoc.getDoctype()) != null) && (saveDoc.getDoctype().getInternalSubset() == null)) { |
String docTypeFile = (new File(saveDoc.getDoctype().getSystemId())).getName(); |
docTransformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, docTypeFile); |
docTransformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); |
docTransformer.setOutputProperty(OutputKeys.METHOD, "xml"); |
docTransformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); |
docTransformer.setOutputProperty(OutputKeys.VERSION, "1.0"); |
} |
try { |
/* Create an OutputStream from saveDoc with ftsi as output target. */ |
444,6 → 454,10 |
== null)) { |
String docTypeFile = (new File(saveDoc.getDoctype().getSystemId())).getName(); |
docTransformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, docTypeFile); |
docTransformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); |
docTransformer.setOutputProperty(OutputKeys.METHOD, "xml"); |
docTransformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); |
docTransformer.setOutputProperty(OutputKeys.VERSION, "1.0"); |
} |
try { |
/* Create an OutputStream from saveDoc with ftsi as output target. */ |