Getting exception while reading element for XML - java

I am able to successfully load the XML based property file using below code:
Properties props = new Properties();
InputStream is = SampleConfig.class.getResourceAsStream("/test.properties");
System.out.println(is);
props.loadFromXML(is);
String appId = props.getProperty("favoriteSeason");
System.out.println(appId);
My Property File Code
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="favoriteSeason">test</entry>
<entry key="favoriteFruit">test1</entry>
<entry key="favoriteDay">test2</entry>
</properties>
But however, when I run this I get below exception:
Caused by: org.xml.sax.SAXParseException: The content of element type "properties" must match "(comment?,entry*)".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at java.util.XMLUtils.getLoadingDoc(XMLUtils.java:113)
at java.util.XMLUtils.load(XMLUtils.java:85)

You are trying to use loadFromXML() method to load from a .properties file. I think that is the issue as the stacktrace shows that its not getting the required format of comments-entry type.

Related

How do you configure the spring integration poller after XSD changes have invalidated the fixed-delay and fixed-rate attributes?

Original xml:
<int:poller default="true" task-executor="stepTaskExecutor" fixed-delay="1000">
The fixed-delay attribute is no longer legal, and fails XML parsing in the (eclipse) IDE.
Alternative configuration:
An alternative suggested elsewhere (including https://docs.spring.io/spring-integration/docs/2.0.0.M3/spring-integration-reference/html/samples.html):
<!-- Globally scoped Spring Integration bean resources -->
<!-- see https://stackoverflow.com/questions/73450768/how-to-configure-channels-and-amq-for-spring-batch-integration-where-all-steps-a/73455134#73455134 -->
<!-- see https://stackoverflow.com/questions/28625635/attribute-fixed-rate-is-not-allowed-to-appear-in-element-intpoller -->
<int:poller default="true" task-executor="stepTaskExecutor">
<int:interval-trigger interval="1000"/>
</int:poller>
This passes the XML parsing in the IDE, but fails at runtime
Log snip:
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'int:interval-trigger'. One of '{"http://www.springframework.org/schema/integration":transactional, "http://www.springframework.org/schema/integration":advice-chain}' is expected.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLNamespaceBinder.handleStartElement(Unknown Source)
at org.apache.xerces.impl.XMLNamespaceBinder.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:77)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadDocument(XmlBeanDefinitionReader.java:432)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
... 50 common frames omitted
Please advise.
Use Spring Tool Suite (eclipse), or add the spring tools plugin to your eclipse so that the schema is loaded from the jar file instead of from the internet.
https://spring.io/tools

XPath query in jlibs-xmldog throws NegativeArraySizeException

I have a project in which I try to run queries on XML files using in.jlibs.jlibs-xmldog.2.2.1.
The XPath that I'm using is
(//server[#id=123])[1]
and the file to be queried looks like this
<servers>
<server id="123" name="servername3">
<cpu_count>3</cpu_count>
<ram_gb>3</ram_gb>
<mac>aabbccaabbcc</mac>
<domain>test.internal</domain>
<ip>192.168.1.20</ip>
</server>
<server id="124" name="servername4">
<cpu_count>4</cpu_count>
<ram_gb>4</ram_gb>
<mac>aabbccaabbcc</mac>
<domain>test.internal</domain>
<ip>192.168.1.20</ip>
</server>
<server id="125" name="servername5">
<cpu_count>5</cpu_count>
<ram_gb>5</ram_gb>
<mac>aabbccaabbcc</mac>
<domain>test.internal</domain>
<ip>192.168.1.20</ip>
</server>
</servers>
As you can see, there is already only one result that is returned by the inner xpath statement, but I have some reasons for which I need to do the query like this. Anyway, the same behaviour happens if I have more results returned by the inner statement. I've tested the xpath online and it seems to be valid.
Code:
public static void main(String[] args) throws Exception{
final String filePath = "C:\\Users\\NCsorba\\Desktop\\xml\\sample_11433_entries.xml";
final String xPathExpression = "(//server[#id=123])[1]";
DefaultNamespaceContext namespaceContext = new DefaultNamespaceContext();
namespaceContext.declarePrefix("xsd", Namespaces.URI_XSD);
XMLDog xmlDog = new XMLDog(namespaceContext);
Expression compiledXPath = xmlDog.addXPath(xPathExpression);
XPathResults xPathResults = xmlDog.sniff(new InputSource(filePath)); // exception thrown
// System.out.println(xPathResults.getResult(compiledXPath));
}
Here is the stack trace:
Exception in thread "main" java.lang.NegativeArraySizeException
at jlibs.core.util.LongTreeMap$Values.toArray(LongTreeMap.java:534)
at java.util.ArrayList.<init>(ArrayList.java:178)
at jlibs.xml.sax.dog.expr.nodset.PathEvaluation.finished(PathExpression.java:218)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.fireFinished(LocationEvaluation.java:215)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.finished(LocationEvaluation.java:208)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.resultPrepared(LocationEvaluation.java:190)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.expired(LocationEvaluation.java:176)
at jlibs.xml.sax.dog.path.EventID.expireList(EventID.java:244)
at jlibs.xml.sax.dog.path.EventID.expire(EventID.java:230)
at jlibs.xml.sax.dog.path.EventID.pop(EventID.java:322)
at jlibs.xml.sax.dog.sniff.Event.firePop(Event.java:266)
at jlibs.xml.sax.dog.sniff.Event.pop(Event.java:712)
at jlibs.xml.sax.dog.sniff.Event.onEndDocument(Event.java:587)
at jlibs.xml.sax.dog.sniff.SAXHandler.endDocument(SAXHandler.java:75)
at org.apache.xerces.parsers.AbstractSAXParser.endDocument(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.endEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.skipSpaces(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:189)
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:174)
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:205)
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:212)
at com.hp.oo.content.actions.xml.Main.main(Main.java:24)
--------------- linked to ------------------
javax.xml.xpath.XPathException: java.lang.NegativeArraySizeException
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:192)
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:174)
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:205)
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:212)
at com.hp.oo.content.actions.xml.Main.main(Main.java:24)
Caused by: java.lang.NegativeArraySizeException
at jlibs.core.util.LongTreeMap$Values.toArray(LongTreeMap.java:534)
at java.util.ArrayList.<init>(ArrayList.java:178)
at jlibs.xml.sax.dog.expr.nodset.PathEvaluation.finished(PathExpression.java:218)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.fireFinished(LocationEvaluation.java:215)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.finished(LocationEvaluation.java:208)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.resultPrepared(LocationEvaluation.java:190)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.expired(LocationEvaluation.java:176)
at jlibs.xml.sax.dog.path.EventID.expireList(EventID.java:244)
at jlibs.xml.sax.dog.path.EventID.expire(EventID.java:230)
at jlibs.xml.sax.dog.path.EventID.pop(EventID.java:322)
at jlibs.xml.sax.dog.sniff.Event.firePop(Event.java:266)
at jlibs.xml.sax.dog.sniff.Event.pop(Event.java:712)
at jlibs.xml.sax.dog.sniff.Event.onEndDocument(Event.java:587)
at jlibs.xml.sax.dog.sniff.SAXHandler.endDocument(SAXHandler.java:75)
at org.apache.xerces.parsers.AbstractSAXParser.endDocument(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.endEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.skipSpaces(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:189)
... 4 more
--------------- linked to ------------------
javax.xml.xpath.XPathException: javax.xml.xpath.XPathException: java.lang.NegativeArraySizeException
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:176)
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:205)
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:212)
at com.hp.oo.content.actions.xml.Main.main(Main.java:24)
Caused by: javax.xml.xpath.XPathException: java.lang.NegativeArraySizeException
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:192)
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:174)
... 3 more
Caused by: java.lang.NegativeArraySizeException
at jlibs.core.util.LongTreeMap$Values.toArray(LongTreeMap.java:534)
at java.util.ArrayList.<init>(ArrayList.java:178)
at jlibs.xml.sax.dog.expr.nodset.PathEvaluation.finished(PathExpression.java:218)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.fireFinished(LocationEvaluation.java:215)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.finished(LocationEvaluation.java:208)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.resultPrepared(LocationEvaluation.java:190)
at jlibs.xml.sax.dog.expr.nodset.LocationEvaluation.expired(LocationEvaluation.java:176)
at jlibs.xml.sax.dog.path.EventID.expireList(EventID.java:244)
at jlibs.xml.sax.dog.path.EventID.expire(EventID.java:230)
at jlibs.xml.sax.dog.path.EventID.pop(EventID.java:322)
at jlibs.xml.sax.dog.sniff.Event.firePop(Event.java:266)
at jlibs.xml.sax.dog.sniff.Event.pop(Event.java:712)
at jlibs.xml.sax.dog.sniff.Event.onEndDocument(Event.java:587)
at jlibs.xml.sax.dog.sniff.SAXHandler.endDocument(SAXHandler.java:75)
at org.apache.xerces.parsers.AbstractSAXParser.endDocument(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.endEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.skipSpaces(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at jlibs.xml.sax.dog.XMLDog.sniff(XMLDog.java:189)
... 4 more
I'll appreciate any help! Thanks!

Element <cache> does not allow nested <searchable> elements

When I am trying to use ehcache with an old war, I am getting the following error in JBoss 7.1.0EAP server:
Caused by: net.sf.ehcache.CacheException: Error configuring from input stream. Initial cause was null:10: Element <cache> does not allow nested <searchable> elements.
at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:157)
at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:101)
... 94 more
Caused by: org.xml.sax.SAXException: null:10: Element <cache> does not allow nested <searchable> elements.
at net.sf.ehcache.config.BeanHandler.createChild(BeanHandler.java:121)
at net.sf.ehcache.config.BeanHandler.startElement(BeanHandler.java:73)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:155)
... 95 more
My pom.xml has the following
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.4.5</version>
</dependency>
What am I doing wrong

Can not save char data to xml file in MATLAB

I want to modify xml text information of an svg file in MATLAB.
I renamed the svg file to xml file
system('rename *myfile.svg* *myfile.xml')
got the XML text info:
fid = fopen(‘myfile.xml');
XMLdata = fscanf(fid, '%s');
XMLdata is a char array containing XML text info
Now I can modify the XMLdata using strcmp for eg:
new_claim = strrep(XMLdata, 'Sans', 'Times New Roman')
Now I could not write this XMLdata to an xml file using xmlwrite
xmlwrite('fileout.xml', XMLdata)
I am getting error
Error using javaMethod
Java exception occurred:
javax.xml.transform.TransformerException: java.net.MalformedURLException: no protocol:
<?xmlversion="1.0"encoding="UTF-8"standalone="no"?><!--CreatedwithInkscape(http://www.inkscape.org/)--><svgxmlns:dc="http://purl.org/dc/elements/1.1/"xmlns:cc="http://creativecommons.org/ns#"xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"xmlns:svg="http://www.w3.org/2000/svg"xmlns="http://www.w3.org/2000/svg"xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"width="64"height="48"id="svg3033"version="1.1"inkscape:version="0.48.5r10040"sodipodi:docname="200mn.svg"><defsid="defs3035"/><sodipodi:namedviewid="base"pagecolor="#ffffff"bordercolor="#666666"borderopacity="1.0"inkscape:pageopacity="0.0"inkscape:pageshadow="2"inkscape:zoom="5.916495"inkscape:cx="61.898573"inkscape:cy="54.220135"inkscape:document-units="px"inkscape:current-layer="layer1"showgrid="false"inkscape:window-width="1280"inkscape:window-height="962"inkscape:window-x="-8"inkscape:window-y="-8"inkscape:window-maximized="1"/><metadataid="metadata3038"><rdf:RDF><cc:Workrdf:about=""><dc:format>image/svg+xml</dc:format><dc:typerdf:resource="http://purl.org/dc/dcmitype/StillImage"/><dc:title></dc:title></cc:Work></rdf:RDF></metadata><ginkscape:label="Layer1"inkscape:groupmode="layer"id="layer1"transform="translate(0,-1004.3622)"><textxml:space="preserve"style="font-size:28px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Calibri;-inkscape-font-specification:Calibri"x="1.3270224e-007"y="1035.7983"id="text3049"sodipodi:linespacing="125%"><tspansodipodi:role="line"id="tspan3051"x="1.3270224e-007"y="1035.7983">200m</tspan></text></g></svg>
at com.icl.saxon.IdentityTransformer.transform(IdentityTransformer.java:92)
at com.mathworks.xml.XMLUtils.serializeXML(XMLUtils.java:175)
at com.mathworks.xml.XMLUtils.serializeXML(XMLUtils.java:44)
Caused by: java.net.MalformedURLException: no protocol:
<?xmlversion="1.0"encoding="UTF-8"standalone="no"?><!--CreatedwithInkscape(http://www.inkscape.org/)--><svgxmlns:dc="http://purl.org/dc/elements/1.1/"xmlns:cc="http://creativecommons.org/ns#"xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"xmlns:svg="http://www.w3.org/2000/svg"xmlns="http://www.w3.org/2000/svg"xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"width="64"height="48"id="svg3033"version="1.1"inkscape:version="0.48.5r10040"sodipodi:docname="200mn.svg"><defsid="defs3035"/><sodipodi:namedviewid="base"pagecolor="#ffffff"bordercolor="#666666"borderopacity="1.0"inkscape:pageopacity="0.0"inkscape:pageshadow="2"inkscape:zoom="5.916495"inkscape:cx="61.898573"inkscape:cy="54.220135"inkscape:document-units="px"inkscape:current-layer="layer1"showgrid="false"inkscape:window-width="1280"inkscape:window-height="962"inkscape:window-x="-8"inkscape:window-y="-8"inkscape:window-maximized="1"/><metadataid="metadata3038"><rdf:RDF><cc:Workrdf:about=""><dc:format>image/svg+xml</dc:format><dc:typerdf:resource="http://purl.org/dc/dcmitype/StillImage"/><dc:title></dc:title></cc:Work></rdf:RDF></metadata><ginkscape:label="Layer1"inkscape:groupmode="layer"id="layer1"transform="translate(0,-1004.3622)"><textxml:space="preserve"style="font-size:28px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Calibri;-inkscape-font-specification:Calibri"x="1.3270224e-007"y="1035.7983"id="text3049"sodipodi:linespacing="125%"><tspansodipodi:role="line"id="tspan3051"x="1.3270224e-007"y="1035.7983">200m</tspan></text></g></svg>
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.icl.saxon.IdentityTransformer.transform(IdentityTransformer.java:90)
... 2 more
java.net.MalformedURLException: no protocol:
<?xmlversion="1.0"encoding="UTF-8"standalone="no"?><!--CreatedwithInkscape(http://www.inkscape.org/)--><svgxmlns:dc="http://purl.org/dc/elements/1.1/"xmlns:cc="http://creativecommons.org/ns#"xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"xmlns:svg="http://www.w3.org/2000/svg"xmlns="http://www.w3.org/2000/svg"xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"width="64"height="48"id="svg3033"version="1.1"inkscape:version="0.48.5r10040"sodipodi:docname="200mn.svg"><defsid="defs3035"/><sodipodi:namedviewid="base"pagecolor="#ffffff"bordercolor="#666666"borderopacity="1.0"inkscape:pageopacity="0.0"inkscape:pageshadow="2"inkscape:zoom="5.916495"inkscape:cx="61.898573"inkscape:cy="54.220135"inkscape:document-units="px"inkscape:current-layer="layer1"showgrid="false"inkscape:window-width="1280"inkscape:window-height="962"inkscape:window-x="-8"inkscape:window-y="-8"inkscape:window-maximized="1"/><metadataid="metadata3038"><rdf:RDF><cc:Workrdf:about=""><dc:format>image/svg+xml</dc:format><dc:typerdf:resource="http://purl.org/dc/dcmitype/StillImage"/><dc:title></dc:title></cc:Work></rdf:RDF></metadata><ginkscape:label="Layer1"inkscape:groupmode="layer"id="layer1"transform="translate(0,-1004.3622)"><textxml:space="preserve"style="font-size:28px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Calibri;-inkscape-font-specification:Calibri"x="1.3270224e-007"y="1035.7983"id="text3049"sodipodi:linespacing="125%"><tspansodipodi:role="line"id="tspan3051"x="1.3270224e-007"y="1035.7983">200m</tspan></text></g></svg>
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.icl.saxon.IdentityTransformer.transform(IdentityTransformer.java:90)
at com.mathworks.xml.XMLUtils.serializeXML(XMLUtils.java:175)
at com.mathworks.xml.XMLUtils.serializeXML(XMLUtils.java:44)
Error in xmlwrite (line 83)
javaMethod('serializeXML',...
xmlwrite is a partner function to xmlread and works with a Document Object Model node. If all you want to do is some simple string replacement you could do something like this:
filename = 'myfile.svg';
XMLdata = fileread(filename);
new_claim = strrep(XMLdata, 'Sans', 'Times New Roman');
fid = fopen(filename, 'w+');
fwrite(fid, new_claim);
fclose(fid);
There is no need to rename the file. fileread just reads a file into a string. strrep returns the modified string, so it is actually new_claim that you'd want to save to a file. As you're just working with a string, fwrite can be used to save the new string to file.
The problem seems to be that all spaces (or line breaks) seem to have been removed from your .svg, and so the XML tags aren't recognized properly (e.g.: instead of <svg xmlns ... you have <svgxmlns ... which is supposed to be closed by </svg> etc.)
It seems to be ok after adding the spaces\breaks where needed:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--CreatedwithInkscape(http://www.inkscape.org/)-->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64"
height="48"
id="svg3033"
version="1.1"
inkscape:version="0.48.5r10040"
sodipodi:docname="200mn.svg">
<defs
id="defs3035"/>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="5.916495"
inkscape:cx="61.898573"
inkscape:cy="54.220135"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1280"
inkscape:window-height="962"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"/>
<metadata
id="metadata3038">
<rdf:RDF>
<cc:Work rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1004.3622)">
<text
xml:space="preserve"
style="font-size:28px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Calibri;-inkscape-font-specification:Calibri"
x="1.3270224e-007"
y="1035.7983"
id="text3049"
sodipodi:linespacing="125%">
<tspan
sodipodi:role="line"
id="tspan3051"
x="1.3270224e-007"
y="1035.7983">200m</tspan>
</text>
</g>
</svg>

Oracle hibernate cfg

I am getting this error when trying to start up my hibernate. I am a hibernate newbie so was hoping someone could point out the mistake I made with my cfg. I included the error, hope it is an easy fix, thanks.
<?xml version='1.0' encoding='utf-8'?>
<!-- Database connection settings -->
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:#localhost:1521:orcl"</property>
<property name="connection.username">scott</property>
<property name="connection.password">tiger</property>
<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
</session-factory>
Exception in thread "main" org.hibernate.MappingException: invalid configuration
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2241)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:230)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:71)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2158)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:212)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:71)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2137)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:206)
at HibernateContext.setConfiguration(HibernateContext.java:20)
at HibernateContext.addClass(HibernateContext.java:205)
at HibernateContext.addClasses(HibernateContext.java:216)
at main.main(main.java:8)
Caused by: org.xml.sax.SAXParseException; lineNumber: 14; columnNumber: 89; Attribute "value" must be declared for element type "property".
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndValidate(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.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.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2238)
... 11 more
Try using
<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
As a newbie, you can read entire hibernate documentation at
http://www.hibernate.org/docs
change : connection.driver_class
to official :
hibernate.connection.driver_class
also read this article

Categories

Resources