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>
Related
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
When i change the xsl:include to xsl:import it somehow works and doesnt return an empty file. I am using the Xslt30Processor class and function Xslt30Processor::TransformFiletoFile(), even The transform.c doesnt work. When my xslt has a "xsl:result-document"
statement it also doesnt work.
I even tried using a previous version of Saxon/C (The 1.2.0 series) , and even that didnt work. Is there any option where it enables the use of xsl:include or something.
This works for Java and .NET but not for the C API.
I don't get any errors or exceptions when using JNI.
Please help.
Here a small example which demostrates the problem:
source.xml:
<xml/>
main.xsl:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" encoding="utf-8" standalone="yes"/>
<xsl:include href="referenced.xsl" />
<xsl:template match="/">hello</xsl:template>
</xsl:stylesheet>
referenced.xsl:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:f="my-functions.org"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="2.0">
<xsl:function name="f:next-nr" as="xs:integer">
<xsl:param name="node"/>
<xsl:sequence select="xs:integer(replace($node, '\D', ''))"/>
</xsl:function>
</xsl:stylesheet>
When running the C version of Transform.exe, no errors are returned and no output is produced. I noticed when putting together this test case that it doesn't matter if I change the include to import for this example. If I use the Transform.exe that comes in the tools folder of Saxon 10.6, a file is produced as expected. I can't, however, find any C/C++ files for Saxon 10.6.
The issue with result-document is a separate issue with the same outcome.
I think I have found one reason why the stylesheet fails on compilation, it seems a build/configuration problem with HE not finding categories.xml.
Stack trace from compilation:
Exception in thread "main" java.lang.ExceptionInInitializerError
at net.sf.saxon.regex.RECompiler.escape(Unknown Source)
at net.sf.saxon.regex.RECompiler.parseTerminal(Unknown Source)
at net.sf.saxon.regex.RECompiler.piece(Unknown Source)
at net.sf.saxon.regex.RECompiler.parseBranch(Unknown Source)
at net.sf.saxon.regex.RECompiler.parseExpr(Unknown Source)
at net.sf.saxon.regex.RECompiler.compile(Unknown Source)
at net.sf.saxon.regex.ARegularExpression.<init>(Unknown Source)
at net.sf.saxon.java.JavaPlatform.compileRegularExpression(Unknown Source)
at net.sf.saxon.Configuration.compileRegularExpression(Unknown Source)
at net.sf.saxon.functions.RegexFunction.tryToBindRegularExpression(Unknown Source)
at net.sf.saxon.functions.RegexFunction.makeFunctionCall(Unknown Source)
at net.sf.saxon.functions.Replace.makeFunctionCall(Unknown Source)
at net.sf.saxon.functions.RegexFunctionSansFlags.makeFunctionCall(Unknown Source)
at net.sf.saxon.functions.registry.BuiltInFunctionSet.bind(Unknown Source)
at net.sf.saxon.functions.FunctionLibraryList.bind(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseFunctionCall(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseBasicStep(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseStepExpression(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseRelativePath(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parsePathExpression(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseSimpleMappingExpression(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseUnaryExpression(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseExprSingle(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseFunctionCall(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseBasicStep(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseStepExpression(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseRelativePath(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parsePathExpression(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseSimpleMappingExpression(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseUnaryExpression(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseExprSingle(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseExpression(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parse(Unknown Source)
at net.sf.saxon.expr.parser.ExpressionTool.make(Unknown Source)
at net.sf.saxon.style.StyleElement.makeExpression(Unknown Source)
at net.sf.saxon.style.XSLSequence.prepareAttributes(Unknown Source)
at net.sf.saxon.style.StyleElement.<unknown>(Unknown Source)
at net.sf.saxon.style.StyleElement.processAllAttributes(Unknown Source)
at net.sf.saxon.style.StyleElement.processAllAttributes(Unknown Source)
at net.sf.saxon.style.PrincipalStylesheetModule.processAllAttributes(Unknown Source)
at net.sf.saxon.style.PrincipalStylesheetModule.preprocess(Unknown Source)
at net.sf.saxon.style.Compilation.compilePackage(Unknown Source)
at net.sf.saxon.style.StylesheetModule.loadStylesheet(Unknown Source)
at net.sf.saxon.style.Compilation.compileSingletonPackage(Unknown Source)
at net.sf.saxon.s9api.XsltCompiler.compile(Unknown Source)
at net.sf.saxon.option.cpp.Xslt30Processor.getXslt30Transformer(Unknown Source)
at net.sf.saxon.option.cpp.Xslt30Processor.transformToFile(Unknown Source)
Caused by: java.lang.RuntimeException: Unable to read categories.xml file
at net.sf.saxon.regex.charclass.Categories.build(Unknown Source)
at net.sf.saxon.regex.charclass.Categories.getCategory(Unknown Source)
at net.sf.saxon.regex.charclass.Categories.<clinit>(Unknown Source)
... 47 more
So it is neither xsl:include nor xsl:result-document that causes the compilation failure, it seems the HE build does not have or does not find its categories.xml file when trying to compile the regular expression in the included code.
As a workaround, it might be possible to run SaxonC EE 11.2 without a license (-license:off), I think, as it then simply uses HE features, while somehow the EE package is correctly built to find its categories.xml so it doesn't fail on compiling regular expressions.
I have raised https://saxonica.plan.io/issues/5372 about the categories.xml file failure.
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.
How can I put a Java Applet in my .Net Web Application ?
I'm trying the following code
<applet code="com.griaule.fingerprintsdk.appletsample.FormMain"
archive="C:\Users\lucas\workspace\applet-chave\bin\SignedFingerprintSDKJava.jar, C:\Users\lucas\workspace\applet-chave\bin\SignedFingerprintSDKJavaAppletSample.jar, C:\Users\lucas\workspace\applet-chave\bin\sqljdbc4.jar" height="550" width="550">
</applet>
but i got the following error
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.util.ProgressMonitorAdapter.setProgressFilter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.setupProgress(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.util.ProgressMonitorAdapter.setProgressFilter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.setupProgress(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.util.ProgressMonitorAdapter.setProgressFilter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.setupProgress(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
If I insert into my .net project the .jar, occurs the error IllegalArgumentException, if I insert file:\ before the path of the jar files, occurs the error SecurityException like I said in comments.
Java applet is configured using HTML tags, so reference to .Net is irrelevant here.
I guess that your problem is in manner you are configuring the classpath defined in attribute archive. The jar references specified there must be relative to your codebase. They cannot be absolute file paths on your machine.
You should write something like
first.jar,second.jar
and put the jars in place accessible over HTTP
I am trying to call a web service but facing a strange behavior. we have a web-service running on my server but the code is not open to us so can not see what going on behind the wall
The owner of the service have exposed web based test client UI which take input in a text box and will show the response to testing purpose.This input box is taking the input in the below mentioned format
<CONTENT>
<CONTENTID></CONTENTID>
<DOCUMENTID>DRI2</DOCUMENTID>
<LOCALECODE>en_US</LOCALECODE>
<LATEST_VERSION>false</LATEST_VERSION>
<INCREASEVIEWCOUNT>false</INCREASEVIEWCOUNT>
<ACTIVITY_TYPE></ACTIVITY_TYPE>
</CONTENT>
its working fine on this UI but when i am trying to call this web service through my java code its getting connected as well getting authorized by the service but when i trying to call the above method it giving me the below error message
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXParseException: Content is not allowed in prolog.
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXParseException: Content is not allowed in prolog.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(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.XMLScanner.reportFatalError(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.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 javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.inquira.imwows.generated.ContentServicesSoapBindingStub.getContentRecord(ContentServicesSoapBindingStub.java:262)
at com.inquira.prep.GetWebService.getcontentRecord(GetWebService.java:87)
at com.inquira.prep.TestWs.main(TestWs.java:13)
{http://xml.apache.org/axis/}hostname:umeshawasthi
org.xml.sax.SAXParseException: Content is not allowed in prolog.
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:701)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.inquira.imwows.generated.ContentServicesSoapBindingStub.getContentRecord(ContentServicesSoapBindingStub.java:262)
at com.inquira.prep.GetWebService.getcontentRecord(GetWebService.java:87)
at com.inquira.prep.TestWs.main(TestWs.java:13)
Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(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.XMLScanner.reportFatalError(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.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 javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
... 11 more
below is the code for generating the required XML
inputXml.append("<CONTENT>");
inputXml.append("<CONTENTID>").append("</CONTENTID>");
inputXml.append("<DOCUMENTID>").append("DRI2").append("</DOCUMENTID>");
inputXml.append("<LOCALECODE>").append("en_US").append("</LOCALECODE>");
inputXml.append("<LATEST_VERSION>").append("false").append("</LATEST_VERSION>");
inputXml.append("<INCREASEVIEWCOUNT>").append("false").append("</INCREASEVIEWCOUNT>");
inputXml.append("<ACTIVITY_TYPE>").append("</ACTIVITY_TYPE>");
inputXml.append("</CONTENT>");
and the generated XML is as below
<CONTENT><CONTENTID></CONTENTID><DOCUMENTID>DRI2</DOCUMENTID><LOCALECODE>en_US</LOCALECODE><LATEST_VERSION>false</LATEST_VERSION><INCREASEVIEWCOUNT>false</INCREASEVIEWCOUNT><ACTIVITY_TYPE></ACTIVITY_TYPE></CONTENT>
i even did timing of the generated string something as below
inputXml.toString().trim().replaceFirst("^([\\W]+)<","<");
but unable to find out whats going wrong,one thing i am sure there is some problem in the input XML as its working find on the test Page UI for the same XML
any help in this regard is much appricated
This error is probably related to a byte order mark (BOM) prior to the actual XML content. You need to parse the returned String and discard the BOM, so SAXParser can process the document correctly.
You will find a possible solution here.
to simply remove it, paste your xml file into notepad, you'll see the extra character before the first tag. Remove it & paste back into your file - bof
Check the XML. It is not a valid xml.
Prolog is the first line with xml version info. It ok not to
include it in your xml.
This error is thrown when the parser reads an invalid tag at the start of the document. Normally where the prolog resides.
e.g.
Root/><document>
Root<document>
This error can come if there is validation error either in your wsdl or xsd file. For instance I too got the same issue while running wsdl2java to convert my wsdl file to generate the client.
In one of my xsd it was defined as below
<xs:import schemaLocation="" namespace="http://MultiChoice.PaymentService/DataContracts" />
Where the schemaLocation was empty. By providing the proper data in schemaLocation resolved my problem.
<xs:import schemaLocation="multichoice.paymentservice.DataContracts.xsd" namespace="http://MultiChoice.PaymentService/DataContracts" />
I faced the same issue. Our application running on four application servers and due to invalid schema location mentioned on one of the web service WSDL, hung threads are generated on the servers . The appliucations got down frequently. After corrected the schema Location , the issue got resolved.