Re: embedding output escaping

2005-07-29 Thread J.Pietschmann

Fabrizio Caldas wrote:
In that case I would have to parse the string I'm getting from a 
properties file.

I was trying to avoid that.


I don't think you can avoid that.
If you feed an XML API a string, it will be treated as plain
text, no matter how hard you wish the machinery would magically
detect markup and handle it accordingly.

J.Pietschmann

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: embedding output escaping

2005-07-28 Thread Andreas L Delmelle

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Jul 28, 2005, at 18:42, Fabrizio Caldas wrote:


But in my case I have hrefs mixed with plain text.


I don't know exactly what that string is, but I know it might have 
hrefs.

So my XML, if I was creating one, would look like this:
some text http://sample.com";>click more 
text


In that case I would have to parse the string I'm getting from a 
properties file.


Yep, but there are a number of ways to go about that. Maybe only the 
generateFor() method needs to be altered. (other options include: 
modifying the type of the title member variable from a simple String to 
a composite object or a collection of Strings, but then the setTitle() 
method needs to be changed as well...)


If you know how to use java.util.regex (or any other regexp library) 
then it should be pretty straightforward to match character data and 
sub-elements, and emit the proper SAX events based on the results...




I was trying to avoid that.


Yes, that was obvious, but: Sorry, no can do :-)

The explanation is that if you use the default generateFor() 
implementation, the title string will be entirely read into a character 
array --including any markup characters. Then a characters() event is 
emitted by the ContentHandler, and the parser implementation will 
gladly take care of generating entity references for any &, <, >, " and 
'.


Short of rewriting the parser to emit element events whenever it 
receives markup characters through a characters() event, your only 
option is indeed to parse the string yourself. If it's any consolation: 
rewriting the parser would definitely be more complicated than this. 
:-)



Greetz,

AD
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFC6XzMyHTbFO9b8aARAv7oAKCtT59yYXpudwuAyBOIRYb2qFb1hwCg22va
Mm5ioWcnboCiHB7q/jIsq/w=
=zqTB
-END PGP SIGNATURE-


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: embedding output escaping

2005-07-28 Thread Fabrizio Caldas

Ok. I see where you're coming from.

But in my case I have hrefs mixed with plain text.

So my setTitle might look something like this.

setTitle(String_From_Properties);

I don't know exactly what that string is, but I know it might have hrefs.
So my XML, if I was creating one, would look like this:
some text http://sample.com";>click more text

And the XSLT would be:

  



 
   
 


Since I'm matching  I would like it to be in the XML.
Now making it appear in the XML is solved.
When I create the FO from that XML it also works.
But when I skip the XML/FO and go straight from Obj to PDF, it gets written 
as text.


But I see your point.
In that case I would have to parse the string I'm getting from a properties 
file.

I was trying to avoid that.

Regards,


From: Andreas L Delmelle <[EMAIL PROTECTED]>
Reply-To: fop-users@xmlgraphics.apache.org
To: fop-users@xmlgraphics.apache.org
Subject: Re: embedding output escaping
Date: Thu, 28 Jul 2005 18:24:34 +0200

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Jul 28, 2005, at 16:56, Fabrizio Caldas wrote:

Hi,

I got the escape working for the XML, you're right about being in the 
XMLReader.java that I need to make this change.


In the first generateFor() method that I have I included a call to

handler.processingInstruction(Result.PI_DISABLE_OUTPUT_ESCAPING,null);

This disables output escaping when creating the xml with the 
ExampleObj2XML.


But when I transform to PDF using the ExampleObj2PDF the escaping does not 
work.


Well, I still think you don't need to do any escaping (or disable escaping 
for that matter).


If you need to have:
Click here

There are two things to take into account:
- - our example embedding.tools.AbstractObjectReader doesn't activate 
namespace support

- - and it does not offer any support for attributes

You basically have two options:
1) modify the code for AbstractObjectReader to allow namespaces and 
attributes (or override the relevant methods in a subclass)

2) generate semantic XML from your object, then transform it via XSLT to FO

For 2), the scenario would look something like:
* use a method similar to setTitle() to set/store the strings for the 
destination URL and "Click here". For example store it in member variables 
named linkContent and linkDest (and provide getXXX() methods to retrieve 
them)


* then, in your XMLReader in the generateFor() method that will process 
your object, you create the result element roughly as follows:

...
handler.startElement("link");
handler.element("destination",obj.getLinkDest());
handler.element("content",obj.getLinkContent());
handler.endElement("link");
...

You will then get XML output like this:


  URL
  Click here


This fragment can be transformed by an XSL template:


  

  


HTH!

Greetz,

AD
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFC6QbLyHTbFO9b8aARAvJjAKCMLiPYet/aCXFS7JBEg1RGBRf2GQCdHA74
+HKtu2LMlsYDDGy4KRKQ2XU=
=Gu0x
-END PGP SIGNATURE-


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



_
MSN Messenger: converse online com seus amigos .  
http://messenger.msn.com.br



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: embedding output escaping

2005-07-28 Thread Andreas L Delmelle

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Jul 28, 2005, at 16:56, Fabrizio Caldas wrote:

Hi,

I got the escape working for the XML, you're right about being in the 
XMLReader.java that I need to make this change.


In the first generateFor() method that I have I included a call to

handler.processingInstruction(Result.PI_DISABLE_OUTPUT_ESCAPING,null);

This disables output escaping when creating the xml with the 
ExampleObj2XML.


But when I transform to PDF using the ExampleObj2PDF the escaping does 
not work.


Well, I still think you don't need to do any escaping (or disable 
escaping for that matter).


If you need to have:
Click here

There are two things to take into account:
- - our example embedding.tools.AbstractObjectReader doesn't activate 
namespace support

- - and it does not offer any support for attributes

You basically have two options:
1) modify the code for AbstractObjectReader to allow namespaces and 
attributes (or override the relevant methods in a subclass)
2) generate semantic XML from your object, then transform it via XSLT 
to FO


For 2), the scenario would look something like:
* use a method similar to setTitle() to set/store the strings for the 
destination URL and "Click here". For example store it in member 
variables named linkContent and linkDest (and provide getXXX() methods 
to retrieve them)


* then, in your XMLReader in the generateFor() method that will process 
your object, you create the result element roughly as follows:

...
handler.startElement("link");
handler.element("destination",obj.getLinkDest());
handler.element("content",obj.getLinkContent());
handler.endElement("link");
...

You will then get XML output like this:


  URL
  Click here


This fragment can be transformed by an XSL template:


  

  


HTH!

Greetz,

AD
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFC6QbLyHTbFO9b8aARAvJjAKCMLiPYet/aCXFS7JBEg1RGBRf2GQCdHA74
+HKtu2LMlsYDDGy4KRKQ2XU=
=Gu0x
-END PGP SIGNATURE-


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: embedding output escaping

2005-07-28 Thread Fabrizio Caldas
I got the escape working for the XML, you're right about being in the 
XMLReader.java that I need to make this change.


In the first generateFor() method that I have I included a call to

handler.processingInstruction(Result.PI_DISABLE_OUTPUT_ESCAPING,null);

This disables output escaping when creating the xml with the ExampleObj2XML.

But when I transform to PDF using the ExampleObj2PDF the escaping does not 
work.


Still trying

Regards,


From: Andreas L Delmelle <[EMAIL PROTECTED]>
Reply-To: fop-users@xmlgraphics.apache.org
To: fop-users@xmlgraphics.apache.org
Subject: Re: embedding output escaping
Date: Thu, 28 Jul 2005 02:33:59 +0200

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Jul 27, 2005, at 23:57, Fabrizio Caldas wrote:

Hi,

This question has probably come up before, but couldn't find it in the 
archives. I want to disable output escaping.


Here's an example:
public static ObjXml createSampleObj() {
 ObjXml obj = new ObjXml();

 obj.setTitle("http://www.sample.com\";>Sample Title");
}

public static void main(String[] args) {
 app.convertObj2XML(obj, "C:\\xmlfile.xml");
 app.convertObj2PDF(obj, "C:\\pdffile.pdf");
}

The xml output is '<';a href="http://www.sample.com";'>';Sample 
Title'<';/a>'; And on the PDF its just text not a link.




First things first: Neither in PDF nor in XSL-FO can this be considered a 
link, since after all, it IS an HTML element.


The correct FO syntax that corresponds to this HTML :

Click here

is

Click here


Does anyone know how to escape this?


Not exactly, nor do I believe you really need to. I think your problem is 
caused by the internals of the methods ObjXml.setTitle() and 
app.convertObj2XML().
Presumably, the first stores the text as a java.lang.String member variable 
of the object in question, while the second writes that String to the 
output XML file --as text, so escaping the usual markup characters and/or 
quotes.
(Analogous to our own embedding example: in ProjectTeam.java, the 
setProjectName() method is only used to store the name as a String. If you 
look at ProjectTeamXMLReader.java, you will see that ultimately a new 
projectname-element is created and the name is only used as its content.)


I have a feeling the setTitle() method is incorrectly being used. You 
expect it to magically transform character data containing markup - --HTML 
markup no less-- to a FO element in the output file.
If you just take a closer look at that embedding example, I think you'll be 
able to figure it out. If not, just yell.



HTH!

Greetz,

AD
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFC6CgFyHTbFO9b8aARAljVAKC7zzh2HdZoa3qC4ustw992bmAd1wCgvBYr
9CKrDkObMtStVVQPy+o34Uo=
=fU8S
-END PGP SIGNATURE-


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



_
Chegou o que faltava: MSN Acesso Grátis. Instale Já! 
http://www.msn.com.br/discador



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: embedding output escaping

2005-07-27 Thread Andreas L Delmelle

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Jul 27, 2005, at 23:57, Fabrizio Caldas wrote:

Hi,

This question has probably come up before, but couldn't find it in the 
archives. I want to disable output escaping.


Here's an example:
public static ObjXml createSampleObj() {
 ObjXml obj = new ObjXml();

 obj.setTitle("http://www.sample.com\";>Sample Title");
}

public static void main(String[] args) {
 app.convertObj2XML(obj, "C:\\xmlfile.xml");
 app.convertObj2PDF(obj, "C:\\pdffile.pdf");
}

The xml output is '<';a href="http://www.sample.com";'>';Sample 
Title'<';/a>'; And on the PDF its just text not a link.




First things first: Neither in PDF nor in XSL-FO can this be considered 
a link, since after all, it IS an HTML element.


The correct FO syntax that corresponds to this HTML :

Click here

is

Click here


Does anyone know how to escape this?


Not exactly, nor do I believe you really need to. I think your problem 
is caused by the internals of the methods ObjXml.setTitle() and 
app.convertObj2XML().
Presumably, the first stores the text as a java.lang.String member 
variable of the object in question, while the second writes that String 
to the output XML file --as text, so escaping the usual markup 
characters and/or quotes.
(Analogous to our own embedding example: in ProjectTeam.java, the 
setProjectName() method is only used to store the name as a String. If 
you look at ProjectTeamXMLReader.java, you will see that ultimately a 
new projectname-element is created and the name is only used as its 
content.)


I have a feeling the setTitle() method is incorrectly being used. You 
expect it to magically transform character data containing markup 
- --HTML markup no less-- to a FO element in the output file.
If you just take a closer look at that embedding example, I think 
you'll be able to figure it out. If not, just yell.



HTH!

Greetz,

AD
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFC6CgFyHTbFO9b8aARAljVAKC7zzh2HdZoa3qC4ustw992bmAd1wCgvBYr
9CKrDkObMtStVVQPy+o34Uo=
=fU8S
-END PGP SIGNATURE-


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



embedding output escaping

2005-07-27 Thread Fabrizio Caldas

Hello everyone,

This question has probably come up before, but  couldn't find it in the 
archives

I want to disable output escaping.

Here's an example:
public static ObjXml createSampleObj() {
 ObjXml obj = new ObjXml();

 obj.setTitle("http://www.sample.com\";>Sample Title");
}

public static void main(String[] args) {
 app.convertObj2XML(obj, "C:\\xmlfile.xml");
 app.convertObj2PDF(obj, "C:\\pdffile.pdf");
}

The xml output is '<';a href="http://www.sample.com";'>';Sample 
Title'<';/a>';

And on the PDF its just text not a link.

Does anyone know how to escape this?

Fabrizio.

_
Chegou o que faltava: MSN Acesso Grátis. Instale Já! 
http://www.msn.com.br/discador



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]