Transformation and Java
Added by Anonymous over 19 years ago
Legacy ID: #3176051 Legacy Poster: hitman2005 (hitman2005)
Hi, I can't solve out my problem with the transformation. I wrote a fragment of code about the transformation at 25-04-2005 and, even if the transformation not throws exceptions, it produce no result. More than this, I use a lot of times the transformation and in each time it produces the right files but in the midst it doesn't work (and without exceptions).Why? I've tried to produce the output with System.out but nothing changed. What can I do? Should I launch the XMLParser before the Transformation? If so, what should I write? Thank you
Replies (8)
Please register to reply
RE: Transformation and Java - Added by Anonymous over 19 years ago
Legacy ID: #3176169 Legacy Poster: Michael Kay (mhkay)
The most likely reason that a transformation produces no result is that your XSLT code is wrong. You haven't actually shown us any XSLT code yet. Try to run your transformation from the command line before you try running it from your own Java code. Then if you still don't understand what's going on, collect together enough information so that someone else can reproduce the problem and hopefully tell you where you have gone wrong. I'm sorry, this is obviously frustrating for you, but we're not going to be able to help you solve it without knowing exactly what you did and exactly what the result was. Michael Kay Saxonica Limited
RE: Transformation and Java - Added by Anonymous over 19 years ago
Legacy ID: #3176342 Legacy Poster: hitman2005 (hitman2005)
Excuse me the code is the following: (I launch the trasformation calling ProduceQuery with the parameters that are files not opened and no parsed: this fragment of code I call about 7 times and each time I use as input document the document produced in the previous transformation) public void ProduceQuery(String xmlti, String xslt, String xmltf) throws Exception { try{ File xml = new File(xmlti); File xsl = new File(xslt); File fine = new File(xmltf); System.setProperty("javax.xml.transform.TransformerFactory","net.sf.saxon.TransformerFactoryImpl"); TransformerFactory tfactory = TransformerFactory.newInstance(); StreamSource xslSource = new StreamSource(xsl.toURI().toString()); // Create a transformer for the stylesheet. Transformer transformer = tfactory.newTransformer(xslSource); StreamSource xmlSource = new StreamSource(xml.toURI().toString()); StreamResult result = new StreamResult(fine); // Transform the source XML to System.out. transformer.transform(xmlSource, result); } catch (Exception e) { e.printStackTrace(); } } Please help me, I tried a lot of solution but I can't still understand why it doesn't work. Thank you a lot
RE: Transformation and Java - Added by Anonymous over 19 years ago
Legacy ID: #3176378 Legacy Poster: Michael Kay (mhkay)
You are still showing me your Java code, I thought I made it fairly clear I needed to see the XSLT code (and the source XML), and I wanted to know whether the transformation worked OK if you run it from the command line. Michael Kay
RE: Transformation and Java - Added by Anonymous over 19 years ago
Legacy ID: #3176381 Legacy Poster: Michael Kay (mhkay)
By the way, a simple little point: you may find that people are more inclined to help you if you stop trying to hide your identity.
RE: Transformation and Java - Added by Anonymous over 19 years ago
Legacy ID: #3176416 Legacy Poster: hitman2005 (hitman2005)
Ok, I appreciate your advise the first XML source document is an access log file (format xml) and the XSL code is on a file that depending on a graphical diagram created by the user, produces a query and then the program applies this query to produce the sequences of navigation in format html. I don't attach it here because it's very long and it is only one of the 7 files XSL I use. The code in line of command is: java -mx512M -DentityExpansionLimit=128000 -jar lib/saxon.jar access-sorted.xml results/$QUERY_NAME/query.xsl > results/$QUERY_NAME/$day-sessions.xml~ and it works fine without problem. I can't traduce the three options (-mx512M -DentityExpansionLimit=128000 -jar ) in java code (I use jdk1.4) and so I omitted. Thank you very much Marco Tammuzzo
RE: Transformation and Java - Added by Anonymous over 19 years ago
Legacy ID: #3176432 Legacy Poster: Michael Kay (mhkay)
Thanks Marco. I think you have to break this problem down into pieces until there is a piece that's small enough for you to demonstrate and small enough that other people can try it out and debug it for you. Otherwise I'm sorry, but there's not much I can do to help. All you've really told me is that it's not working and you don't know why. Michael Kay
RE: Transformation and Java - Added by Anonymous over 19 years ago
Legacy ID: #3176437 Legacy Poster: hitman2005 (hitman2005)
Thank you very much. Do you think that using before the transformation the parser on the document and then launching the transformation it will work? Marco Tammuzzo
RE: Transformation and Java - Added by Anonymous over 19 years ago
Legacy ID: #3176508 Legacy Poster: Michael Kay (mhkay)
No, I can't see why that should make any difference, but at the moment I have no idea what the nature of the failure is, so I can't really tell. Michael Kay
Please register to reply