• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: roblem with XSLT Trasformations - was problem generating PDF using FOP
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: roblem with XSLT Trasformations - was problem generating PDF using FOP


  • Subject: Re: roblem with XSLT Trasformations - was problem generating PDF using FOP
  • From: Amedeo Mantica <email@hidden>
  • Date: Wed, 11 Oct 2006 18:52:37 +0200

Hello all who are helping me in this trouble.

Thank you for all support

We are in right direction but there is still encoding problems, I'm trying everything.

Now I'm trying STEP STEP bug finding, starting with outputting fo a file the serialized EORecord

public pdfScheda xmlpdf() throws Exception
{
pdfScheda nextPage = (pdfScheda)pageWithName("pdfScheda");
String myXml = XMLSerializer.serializeProduct(theProduct);
System.out.println("JUST SERIALIZED: "+myXml);


FileOutputStream out = new FileOutputStream("/tmp/mainXml.xml");
out.write(myXml.getBytes("UTF-8"));
out.flush();
out.close();

return nextPage;
}

file is written to hd, but is NOT utf-8 
If you open it with BBedit it renders ok because of UTF-8 xml declaration, but is bad opeding with pico

public static String serializeProduct(product aProduct) throws UnsupportedEncodingException, Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
// Create a stream to the output file.

BufferedOutputStream byte_output_stream = new BufferedOutputStream(out);
NSXMLOutputStream stream = new NSXMLOutputStream(byte_output_stream);

// Set the format of the output document (XML).
NSXMLOutputFormat format = new NSXMLOutputFormat(true);

format.setEncoding("UTF-8");
// turn indentation on               
stream.setOutputFormat(format); // app


// Serialize data to object output stream.
stream.writeObject(aProduct);

stream.flush();
stream.close();
byte_output_stream.close();

} catch (IOException e) {
e.printStackTrace();
}
return out.toString("UTF-8");


XMLSerializer.serialize methid here:

public static String serializeProduct(product aProduct) throws UnsupportedEncodingException, Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
// Create a stream to the output file.

BufferedOutputStream byte_output_stream = new BufferedOutputStream(out);
NSXMLOutputStream stream = new NSXMLOutputStream(byte_output_stream);

// Set the format of the output document (XML).
NSXMLOutputFormat format = new NSXMLOutputFormat(true);

format.setEncoding("UTF-8");
// turn indentation on               
stream.setOutputFormat(format); // app


// Serialize data to object output stream.
stream.writeObject(aProduct);

stream.flush();
stream.close();
byte_output_stream.close();

} catch (IOException e) {
e.printStackTrace();
}


FileOutputStream justSerializedXml = new FileOutputStream("/tmp/justSerializedXml.xml");
justSerializedXml.write(out.toByteArray());
justSerializedXml.close();


return out.toString("UTF-8");
}

also file /tmp/justSerializedXml.xml is lookong bad.

Regards
Amedeo



On 11/ott/06, at 00:42, Travis Cripps wrote:

Amadeo,

Hi.  I created a sample project from your files, and was initially getting the same result, with the characters in the file resulting from your transform being messed up.

I changed all instances of String -> byte[] and byte[] -> String conversions to specify the character encoding and the resulting xml was perfect.

The basic changes were to read the xml and xsl into Strings like this:

String sourceXML = null;
byte[] bytes = WOApplication.application().resourceManager().bytesForResourceNamed("sourceXML.xml", null, null);
try {
sourceXML = new String(bytes, "UTF-8");
} catch (UnsupportedEncodingException uee) {
uee.printStackTrace();
}

and to get the result of the transformation like this:

try {
result = ((ByteArrayOutputStream)((StreamResult) output).getOutputStream()).toString("UTF-8");
} catch (UnsupportedEncodingException uee) {
uee.printStackTrace();
}

I've posted the simple project to http://apparentmotion.com/downloadables/XSLTest.zip. (47 KB)

Have a great day.

Travis

On Oct 10, 2006, at 3:36 AM, Amedeo Mantica wrote:

Thank you for reply and collaboration

here the link for dile downloads

http://downloads.insigno.net/fileswo.zip

the sourceXML is the XML data grabbed from database (using WebObjects's NSXMLOutputStream)
the file is perfect.  (some /u000d for CR/LF, but I think is ok)

the SimpleTrasformation.xls is an Apple provided XLST file for removing unuseful data and simplyfing the XML file.

the destinationXML file is the result of sourceXML trasformed using SimpleTrasformation.xml
myTrasformer.java is the routine that do the XSLT trasformation.

see the accented letters in destinationXML file...

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: roblem with XSLT Trasformations - was problem generating PDF using FOP (From: Amedeo Mantica <email@hidden>)
 >Re: roblem with XSLT Trasformations - was problem generating PDF using FOP (From: Travis Cripps <email@hidden>)

  • Prev by Date: Re: Tomcat deployment woes
  • Next by Date: Re: roblem with XSLT Trasformations - was problem generating PDF using FOP
  • Previous by thread: Re: [partially solved] problem with XSLT Trasformations - was problem generating PDF using FOP
  • Next by thread: Re: roblem with XSLT Trasformations - was problem generating PDF using FOP
  • Index(es):
    • Date
    • Thread