| 
 | |||||||
| 
 | 
|  | 
|  | 
|  | Strumenti | 
|  14-03-2010, 23:29 | #1 | 
| Member Iscritto dal: Jan 2008 
					Messaggi: 109
				 | 
				
				[java] problema con config.xml
			 
		salve vorrei salvare le impostazioni del mio programma in un file interno al jar. file config.xml Codice:  <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
 <?xml version="1.0" encoding="UTF-8"?>
    <!-- DTD for properties -->
    <!ELEMENT properties ( comment?, entry* ) >
    <!ATTLIST properties version CDATA #FIXED "1.0">
    <!ELEMENT comment (#PCDATA) >
    <!ELEMENT entry (#PCDATA) >
    <!ATTLIST entry key CDATA #REQUIRED>Codice:  Properties properties = new Properties();
		InputStream fis = getClass().getResourceAsStream ("/config.xml");
		 try {
			properties.loadFromXML(fis);
		} catch (InvalidPropertiesFormatException e1) {
			e1.printStackTrace();
		} catch (IOException e1) {
			e1.printStackTrace();
		}Codice: java.util.InvalidPropertiesFormatException: org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed. at java.util.XMLUtils.load(Unknown Source) at java.util.Properties.loadFromXML(Unknown Source) at gui.MindCopy.caricaPreferenze(MindCopy.java:130) at gui.Mind2.getJFrame(Mind2.java:105) at gui.Mind2.access$4(Mind2.java:82) at gui.Mind2$13.run(Mind2.java:695) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) Caused by: org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanPIData(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanPIData(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanPI(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at java.util.XMLUtils.getLoadingDoc(Unknown Source) ... 14 more Ultima modifica di nicolad1988 : 14-03-2010 alle 23:31. | 
|   |   | 
|  15-03-2010, 16:11 | #2 | 
| Member Iscritto dal: Jan 2008 
					Messaggi: 109
				 | 
		help nessuno sà rispondermi   | 
|   |   | 
|  15-03-2010, 17:43 | #3 | 
| Member Iscritto dal: Jan 2008 Città: roma 
					Messaggi: 296
				 | 
		il tuo config.xml non e un xml ma un dtd ... cioè la definizione della struttura del xml ... (che tu hai copiato dal sito della sun   ) ... il tuo xml deve essere composto da un elemento root "properties"  con zero o un tag "comment" e zero o più tag "entry" . il tag entry deve avere definito l'attributo key ... Codice: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>commento</comment> <entry key="property1">value1</entry> <entry key="property2">value2</entry> </properties> cmq bastava definire 2,3 proprietà e invocare il metodo "inverso" storeToXML   | 
|   |   | 
|  15-03-2010, 23:33 | #4 | 
| Member Iscritto dal: Jan 2008 
					Messaggi: 109
				 | 
		grazie mille non conosco questo ambito..si può chiudere   | 
|   |   | 
|   | 
| Strumenti | |
| 
 | 
 | 
Tutti gli orari sono GMT +1. Ora sono le: 09:00.









 
		 
		 
		 
		






 
  
 



 
                        
                        










