Link to home
Start Free TrialLog in
Avatar of miraodb
miraodb

asked on

java.net.URISyntaxException: Illegal character in opaque part

hi,

i've been working on a project where i needed to transform xml into hmtl using xsl with saxon.
so i used the following code:
System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl");
Source xmlSource = new StreamSource("C:\\installaxiom\\axiom_app\\class\\XMLFile.xml");
Source xsltSource = new StreamSource("C:\\installaxiom\\axiom_app\\class\\XMLFile.xsl");
Result result = new StreamResult(out);
TransformerFactory transFact = TransformerFactory.newInstance(  );
Transformer trans = transFact.newTransformer(xsltSource);
trans.transform(xmlSource, result);

it works fine and then i want to use the xmlfile and another xsl to create a new xml file as follows:
Source xmlSource2 = new StreamSource("C:\\installaxiom\\axiom_app\\class\\XMLFile.xml");
                        Source xsltSource2 = new StreamSource("C:\\installaxiom\\axiom_app\\class\\RawToTreeDataXML.xsl");
Result result2 = new StreamResult("C:\\installaxiom\\axiom_app\\class\\TreeDataXML.xml");
TransformerFactory transFact2 = TransformerFactory.newInstance(  );
Transformer trans2 = transFact2.newTransformer(xsltSource2);
trans2.transform(xmlSource2, result2);

but i get this error:
javax.servlet.ServletException: java.net.URISyntaxException: Illegal character in opaque part at index 2: C:\installaxiom\axiom_app\class\TreeDataXML.xml

which i don't understand coz i'm using on both xml the same encoding which is "iso-8859-1".
if i try to apply the xsl to the xml in command line it works fine.

any ideas?

thankx in advance to all
miraodb
Avatar of PointyEars
PointyEars

I am not familiar with what you are doing, but I found that the colon in a path is not always handled properly.

If C is the boot volume, you should be able to drop "C:" from your path and start directly with "\\installaxiom".

Perhaps a long shot and I wouldn't be able to help you further if this didn't work, but it is easy to try it out...
Avatar of miraodb

ASKER

well i just tried and it still shows the same error.
anyway i didn't see why it would work for the first transformation and not for the second.

i really have no idea of what's goin' on !

miraodb
Check the namespace URI / URL
Or check the any there exists any links to external documents such as Schemas
Avatar of miraodb

ASKER

i'm using jsp to execute an xsl on an xsl, so when i get the error javax.servlet.ServletException: java.net.URISyntaxException: Illegal character in opaque part at index 2: C:\installaxiom\axiom_app\class\TreeDataXML.xml

the actual file treedata.xml doesn't exist yet ! so schemas shouldn't be a problem at this point.
and also it works fine under the command line.

the namespace of which one the original xml? it's:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

i don't think this should interfere here.
SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of miraodb

ASKER

thankx to both of you.

i splited the points.

miraodb
>>this works for absolute and relative paths...

Easier and less error-prone to do:

new StreamSource(new File("C:/installaxiom/axiom_app/class/XMLFile.xml").toURL());
:-)