Re: [Digester] HTML entity decoding?

2009-04-15 Thread Paul Libbrecht

Hello Otis,

For the second form you'll need to hook a DTD to do so. A DTD  
declaration in your header pointing to a DTD which defines these  
entities I am no expert in Digester but I believe that it is the only  
way to do so. At least according to the XML specs.


Here's a text pointing to such a DTD:
  
http://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_xhtml_character_entities

Note that opening the file with a validating parser will certainly  
grumble about all sorts of undeclared elements, this is ok, it does  
not prevent parsing but is, indeed, a validation error.

However you get the entity-expansion.

Note that using the first form, which contains an *escaped* entity,  
there's nothing to do! You'd have to match them manually ("re- 
entrantly") into a parser that parses entities properly.


paul

PS: I would feel lucky not to have been blown away the XML parsing in  
the second case as a normal XML parser does: missing entity  
declaration means unparseable XML while missing element declaration  
means much less a dangerous thing.


Le 16-avr.-09 à 00:06, Otis Gospodnetic a écrit :



Hello,

I'm using Digester 2.0 and trying to process XML that
may include HTML entities and trying to get Digester to decode them
when parsing.

For example, my XML contains:
 

Currently, Digester is parses this as:  Grüber

But what I am really after is "Grüber", so I am looking for a way to  
get this ü entity decoded by Digester.

How do I tell Digester to decode HTML entities?

Also, if I don't use CDATA, like this:
 Grüber

Digester gives me: Grber




smime.p7s
Description: S/MIME cryptographic signature


[Digester] HTML entity decoding?

2009-04-15 Thread Otis Gospodnetic

Hello,

I'm using Digester 2.0 and trying to process XML that
may include HTML entities and trying to get Digester to decode them
when parsing.

For example, my XML contains:
  

Currently, Digester is parses this as:  Grüber

But what I am really after is "Grüber", so I am looking for a way to get this 
ü entity decoded by Digester.
How do I tell Digester to decode HTML entities?

Also, if I don't use CDATA, like this:
  Grüber

Digester gives me: Grber

Any help would be very appreciated.  Thanks,

Otis
--
Sematext -- http://sematext.com/ -- Lucene - Solr - Nutch

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: HTTP proxy for commons XMLConfiguration

2009-04-15 Thread Oliver Heger

Christoph Jaehnigen schrieb:

Hi, I need some advice with the Commons Configuration library.

I use a XML file for configuration storage which has a DTD specified
being reachable by a HTTP URI. I need to use a HTTP proxy on the
executing machine.

When I try to load the XML configuration, also with setValidate() to
false I get a ConfigurationException with the message: Unable to load
the configuration. When removing the DTD statement the configuration
loads just fine.

So: is Apache commons-configuration HTTP proxy aware? Does it use the
actual JVM settings? I also tried to use the -Dhttp.proxyHost system
properties settings with no success.

So, how to do it? Btw. machine is WinXP and I'm using Eclipse as IDE
with m2eclipse for Maven support.

Thx
Chris



Hm, good question.

XMLConfiguration does not load the DTD on its own, but relies on the XML 
parser used. The parser itself is obtained using a default 
DocumentBuilderFactory. I would expect that the XML parser understands 
the proxy-related system variables and uses them if they are set. (Note 
that the DTD has to be loaded in any case, even if validation is 
disabled, because it might contain entity definitions that have to be 
resolved.)


For performance reasons it would be better not to load the DTD from a 
HTTP server, but ship a local copy with your application. You can put it 
somewhere on the class path. You can then use the method 
registerEntityId() of XMLConfiguration to map the public ID of the DTD 
to a local resource. That way no network access is required.


Oliver



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [SCXML] getting set datats in the datamodel

2009-04-15 Thread Rahul Akolkar
On Wed, Apr 15, 2009 at 12:34 PM, Linda Erlenhov
 wrote:
> Hello
> So I´m back here again.
>
> My problem now is that I don´t know how to notify.
> I looked at the solution suggested below since I thought it would be the
> easiest and best looking way to implement this.
>
> The way my first solution worked was to use Observer and Observable. Since
> Observable is a class I could not extend SimpleContext aswell (since
> multiple inheritance from classes is not ok in java) so i just "copied"
> SimpleContext instead since it only implemented two Interfaces, extended
> Observable and modifyed it according to my liking.


I'd do it the other way, extend the Context implementation and add
observable functionality since I claim the latter is the simpler bit
(lower case o here, not referring to the java.util class -- minimally,
(a) maintain a list of observers as an instance field, (b) have an
adder method that adds observers to the list and (c) have the notify
method in question iterate over the observers to notify them of the
value change).


> The problem then was that
> to user timers (as I was asking about in another thread) and they use JEXL.
> So to make the timers work I have to use an JEXL or JEXL extended class. And
> there goes my Observable.
>


Timers don't need JEXL, you can continue using whatever EL you were
using (extend the corresponding Context and Evaluator implementations
-- if you were in fact using Commons JEXL, you'd extend JexlContext
and JexlEvaluator and so on).


> I am aware that this might be a java question instead of a SCXML question
> and if so I apologise. Maybe you can see something that I have missed or
> help me with where I should post this question. I´ve stared a bit too long
> at my code by now. Is there another way to do this?
>


Its a bit more of a Java question than an SCXML question, yes. You
could post to any Java forums / try search engines.

-Rahul


> best regards
> //Linda
>
>
>> >>
>> >>  * Use a custom Context implementation - This will allow you to
>> >> intercept data changes, à la pointcut at
>> >> oacs.Context#set(String,Object), and get notifications that way
>> >
>> >
>> > This could possibly be of intrest, but I´m still not 100% sure on how the
>> > context works. Where would these notifications "arrive"
>> >
>> 
>>
>> This is another approach, some background:
>>
>>  http://commons.apache.org/scxml/guide/contexts-evaluators.html
>>
>> I'll sketch an outline here -- say we have MyContext extending
>> SimpleContext where MyContext#set(String,Object) looks like:
>>
>>   public void set(String name, Object value) {
>>      // inherit behavior
>>      super.set(name, value);
>>      // notifications you need
>>      notify(name, value);
>>   }
>>
>> and a MyEvaluator extending the Evaluator you are currently using
>> whose newContext() method does this:
>>
>>   public Context newContext(Context parent) {
>>      return new MyContext(parent);
>>   }
>>
>> then using this evaluator with the SCXMLExecutor instances like so:
>>
>>   SCXMLExecutor exec = new SCXMLExecutor();
>>   ...
>>   exec.setEvaluator(new MyEvaluator());
>>
>> ties in the above "pointcut" behavior causing notifications for any
>> data changes within the state machine. Adjust outline per
>> requirements.
>>
>> -Rahul
>>
>>
>> > best regards
>> > //Linda
>> >
>>

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [SCXML] Timers in SCXML

2009-04-15 Thread Rahul Akolkar
On Wed, Apr 15, 2009 at 11:02 AM, Linda Erlenhov
 wrote:
> Hello
> Sorry to mass-spam email you, but I solved the problem myself after a food
> break and some more thinking.  The problem was the way I was trying to solve
> the data requests i asked about in another mail. So this is not a problem
> anymore, thank you!
>


This isn't remotely close to spam, in fact its quite useful to know
when issues are resolved so thanks for following up.

-Rahul



> //Linda
>
> On Wed, Apr 15, 2009 at 2:16 PM, Linda Erlenhov 
> wrote:
>
>> Hello again.
>> I run the standalone test and it looks like the timers work fine there (An
>> infinit loop between the two states, the logs, except for those that was
>> nested as you pointed out, are printed one or two seconds apart as specified
>> in the scxml ), so now I´m a bit clueless with how to proceed, any idéas? Is
>> there anything I might have forgotten in my java files since it doesn´t work
>> there?
>>
>> best regards
>> //Linda
>>
>> On Tue, Apr 14, 2009 at 9:11 PM, Rahul Akolkar 
>> wrote:
>>
>>> On Tue, Apr 14, 2009 at 8:19 AM, Linda Erlenhov
>>>  wrote:
>>> > Hello!
>>> >
>>> > This may be a stupid question but:
>>> > I have read through the code for the simple scheduler and I´m  not sure
>>> i
>>> > understand what happens.
>>> > We have written a simple scxml for a small statechart containing two
>>> states
>>> > with timers and used the simple scheduler as described in your previous
>>> > e-mail. As I understand the timers would make the machine just jump
>>> between
>>> > the two states. This doesn´t happen. Why?
>>> 
>>>
>>> The Commons SCXML version and the relevant driver (Java) code will
>>> help towards answering -- we know this works, so we'll need to know
>>> whats being done differently. Bear in mind that the timers execute as
>>> daemons.
>>>
>>> I suggest trying your example standalone [1] first, and we'll go from
>>> there.
>>>
>>> As an aside, in the markup below,  is nested in  which
>>> isn't legal, so the nested  will be ignored.
>>>
>>> -Rahul
>>>
>>> [1] http://commons.apache.org/scxml/guide/testing-standalone.html
>>>
>>>
>>>
>>> > ---
>>> > http://commons.apache.org/scxml"; xmlns="http://www.w3.org/2005/07/scxml
>>> ">
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > -
>>> >
>>> > The output when this is run is simply:
>>> > 2009-apr-14 13:08:57 org.apache.commons.scxml.model.Log execute
>>> > INFO: Renegade: Entering state: A
>>> > 2009-apr-14 13:08:57 org.apache.commons.scxml.env.SimpleScheduler send
>>> > INFO: send ( sendId: 1, target: null, targetType: scxml, event: ToB,
>>> params:
>>> > null, hints: null, delay: 1000)
>>> >
>>> > best regards
>>> > //Linda
>>> >
>>>

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [SCXML] getting set datats in the datamodel

2009-04-15 Thread Linda Erlenhov
Hello
So I´m back here again.

My problem now is that I don´t know how to notify.
I looked at the solution suggested below since I thought it would be the
easiest and best looking way to implement this.

The way my first solution worked was to use Observer and Observable. Since
Observable is a class I could not extend SimpleContext aswell (since
multiple inheritance from classes is not ok in java) so i just "copied"
SimpleContext instead since it only implemented two Interfaces, extended
Observable and modifyed it according to my liking. The problem then was that
to user timers (as I was asking about in another thread) and they use JEXL.
So to make the timers work I have to use an JEXL or JEXL extended class. And
there goes my Observable.

I am aware that this might be a java question instead of a SCXML question
and if so I apologise. Maybe you can see something that I have missed or
help me with where I should post this question. I´ve stared a bit too long
at my code by now. Is there another way to do this?

best regards
//Linda


> >>
> >>  * Use a custom Context implementation - This will allow you to
> >> intercept data changes, à la pointcut at
> >> oacs.Context#set(String,Object), and get notifications that way
> >
> >
> > This could possibly be of intrest, but I´m still not 100% sure on how the
> > context works. Where would these notifications "arrive"
> >
> 
>
> This is another approach, some background:
>
>  http://commons.apache.org/scxml/guide/contexts-evaluators.html
>
> I'll sketch an outline here -- say we have MyContext extending
> SimpleContext where MyContext#set(String,Object) looks like:
>
>   public void set(String name, Object value) {
>  // inherit behavior
>  super.set(name, value);
>  // notifications you need
>  notify(name, value);
>   }
>
> and a MyEvaluator extending the Evaluator you are currently using
> whose newContext() method does this:
>
>   public Context newContext(Context parent) {
>  return new MyContext(parent);
>   }
>
> then using this evaluator with the SCXMLExecutor instances like so:
>
>   SCXMLExecutor exec = new SCXMLExecutor();
>   ...
>   exec.setEvaluator(new MyEvaluator());
>
> ties in the above "pointcut" behavior causing notifications for any
> data changes within the state machine. Adjust outline per
> requirements.
>
> -Rahul
>
>
> > best regards
> > //Linda
> >
>
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
>
>


RE: [dbcp] connection autocommit property

2009-04-15 Thread Wes Clark

We do the same thing, and, yes, the pool doesn't change the state of
autocommit.  It is easy to check when you borrow the connection back
from the pool. 

-Original Message-
From: Melih Utkan UNSAL [mailto:melihut...@yahoo.com] 
Sent: Wednesday, April 15, 2009 7:52 AM
To: user@commons.apache.org
Subject: [dbcp] connection autocommit property

Hi,

i am trying to find the behaviour of dbcp about autocommit property.

i am getting the connection from pool and then setting autocommit
property false .


after doing a few transactions,i commit or rollback the transaction and
then i close the connection so it goes back to the pool.

everthing is ok up to now.

if i get that connection one more time after theese operations, then
what is the autocommit property? False or True ?

i expect to be false because i set it false and sent to pool.

what do you think?


  

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [SCXML] Timers in SCXML

2009-04-15 Thread Linda Erlenhov
Hello
Sorry to mass-spam email you, but I solved the problem myself after a food
break and some more thinking.  The problem was the way I was trying to solve
the data requests i asked about in another mail. So this is not a problem
anymore, thank you!

//Linda

On Wed, Apr 15, 2009 at 2:16 PM, Linda Erlenhov wrote:

> Hello again.
> I run the standalone test and it looks like the timers work fine there (An
> infinit loop between the two states, the logs, except for those that was
> nested as you pointed out, are printed one or two seconds apart as specified
> in the scxml ), so now I´m a bit clueless with how to proceed, any idéas? Is
> there anything I might have forgotten in my java files since it doesn´t work
> there?
>
> best regards
> //Linda
>
> On Tue, Apr 14, 2009 at 9:11 PM, Rahul Akolkar wrote:
>
>> On Tue, Apr 14, 2009 at 8:19 AM, Linda Erlenhov
>>  wrote:
>> > Hello!
>> >
>> > This may be a stupid question but:
>> > I have read through the code for the simple scheduler and I´m  not sure
>> i
>> > understand what happens.
>> > We have written a simple scxml for a small statechart containing two
>> states
>> > with timers and used the simple scheduler as described in your previous
>> > e-mail. As I understand the timers would make the machine just jump
>> between
>> > the two states. This doesn´t happen. Why?
>> 
>>
>> The Commons SCXML version and the relevant driver (Java) code will
>> help towards answering -- we know this works, so we'll need to know
>> whats being done differently. Bear in mind that the timers execute as
>> daemons.
>>
>> I suggest trying your example standalone [1] first, and we'll go from
>> there.
>>
>> As an aside, in the markup below,  is nested in  which
>> isn't legal, so the nested  will be ignored.
>>
>> -Rahul
>>
>> [1] http://commons.apache.org/scxml/guide/testing-standalone.html
>>
>>
>>
>> > ---
>> > http://commons.apache.org/scxml"; xmlns="http://www.w3.org/2005/07/scxml
>> ">
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > -
>> >
>> > The output when this is run is simply:
>> > 2009-apr-14 13:08:57 org.apache.commons.scxml.model.Log execute
>> > INFO: Renegade: Entering state: A
>> > 2009-apr-14 13:08:57 org.apache.commons.scxml.env.SimpleScheduler send
>> > INFO: send ( sendId: 1, target: null, targetType: scxml, event: ToB,
>> params:
>> > null, hints: null, delay: 1000)
>> >
>> > best regards
>> > //Linda
>> >
>>
>> -
>> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
>> For additional commands, e-mail: user-h...@commons.apache.org
>>
>>
>


[dbcp] connection autocommit property

2009-04-15 Thread Melih Utkan UNSAL
Hi,

i am trying to find the behaviour of dbcp about autocommit property.

i am getting the connection from pool and then setting autocommit property 
false .


after doing a few transactions,i commit or rollback the transaction and then i 
close the connection so it goes back to the pool.

everthing is ok up to now.

if i get that connection one more time after theese operations, then what is 
the autocommit property? False or True ?

i expect to be false because i set it false and sent to pool.

what do you think?


  

Re: StrTokenizer not handling quotes correctly?

2009-04-15 Thread sebb
On 15/04/2009, Jacek Furmankiewicz  wrote:
> I am trying to use StrTokenizer for some parsing and I am probably not using
>  it correctly.
>
>  Let's say I have this string:
>
>  11"a,b"11,22"c,d"22"
>
>  I would like to split it by the comma ",", but ignoring any commas embedded
>  in quotes. I try this:
>
> String test = "11\"a,b\"11,22\"c,d\"22";
> StrTokenizer str = new StrTokenizer(test,',','"');
> String[] tokens = str.getTokenArray();
>
> for(String t: tokens) {
> System.out.println(t);
> }
>
>  and expect to have two strings print out:
>
>  11"a,b"11
>  22"c,d"22
>
>  but instead I get 4 :
>
>  11"a
>  b"11
>  22"c
>  d"22
>
>  It seems the tokenizer is splitting on the comma, even if it is embedded in
>  quotes.

Quotes are only allowed in quoted strings. From the Javadoc:

"Each token may be surrounded by quotes. The quote matcher specifies
the quote character(s). A quote may be escaped within a quoted section
by duplicating itself. "

>  I tried different options on the StrTokenizer, but not been able to get it
>  to work correctly.
>
>  Any idea as to what am I doing wrong? Using latest version 2.4.

The input needs to look like this:

"11""a,b""11","22""c,d""22""

>  Thanks, Jacek
>

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



HTTP proxy for commons XMLConfiguration

2009-04-15 Thread Christoph Jaehnigen
Hi, I need some advice with the Commons Configuration library.

I use a XML file for configuration storage which has a DTD specified
being reachable by a HTTP URI. I need to use a HTTP proxy on the
executing machine.

When I try to load the XML configuration, also with setValidate() to
false I get a ConfigurationException with the message: Unable to load
the configuration. When removing the DTD statement the configuration
loads just fine.

So: is Apache commons-configuration HTTP proxy aware? Does it use the
actual JVM settings? I also tried to use the -Dhttp.proxyHost system
properties settings with no success.

So, how to do it? Btw. machine is WinXP and I'm using Eclipse as IDE
with m2eclipse for Maven support.

Thx
Chris

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



StrTokenizer not handling quotes correctly?

2009-04-15 Thread Jacek Furmankiewicz
I am trying to use StrTokenizer for some parsing and I am probably not using
it correctly.

Let's say I have this string:

11"a,b"11,22"c,d"22"

I would like to split it by the comma ",", but ignoring any commas embedded
in quotes. I try this:

String test = "11\"a,b\"11,22\"c,d\"22";
StrTokenizer str = new StrTokenizer(test,',','"');
String[] tokens = str.getTokenArray();

for(String t: tokens) {
System.out.println(t);
}

and expect to have two strings print out:

11"a,b"11
22"c,d"22

but instead I get 4 :

11"a
b"11
22"c
d"22

It seems the tokenizer is splitting on the comma, even if it is embedded in
quotes.

I tried different options on the StrTokenizer, but not been able to get it
to work correctly.

Any idea as to what am I doing wrong? Using latest version 2.4.

Thanks, Jacek


Re: [SCXML] Timers in SCXML

2009-04-15 Thread Linda Erlenhov
Hello again.
I run the standalone test and it looks like the timers work fine there (An
infinit loop between the two states, the logs, except for those that was
nested as you pointed out, are printed one or two seconds apart as specified
in the scxml ), so now I´m a bit clueless with how to proceed, any idéas? Is
there anything I might have forgotten in my java files since it doesn´t work
there?

best regards
//Linda

On Tue, Apr 14, 2009 at 9:11 PM, Rahul Akolkar wrote:

> On Tue, Apr 14, 2009 at 8:19 AM, Linda Erlenhov
>  wrote:
> > Hello!
> >
> > This may be a stupid question but:
> > I have read through the code for the simple scheduler and I´m  not sure i
> > understand what happens.
> > We have written a simple scxml for a small statechart containing two
> states
> > with timers and used the simple scheduler as described in your previous
> > e-mail. As I understand the timers would make the machine just jump
> between
> > the two states. This doesn´t happen. Why?
> 
>
> The Commons SCXML version and the relevant driver (Java) code will
> help towards answering -- we know this works, so we'll need to know
> whats being done differently. Bear in mind that the timers execute as
> daemons.
>
> I suggest trying your example standalone [1] first, and we'll go from
> there.
>
> As an aside, in the markup below,  is nested in  which
> isn't legal, so the nested  will be ignored.
>
> -Rahul
>
> [1] http://commons.apache.org/scxml/guide/testing-standalone.html
>
>
>
> > ---
> > http://commons.apache.org/scxml"; xmlns="http://www.w3.org/2005/07/scxml
> ">
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > -
> >
> > The output when this is run is simply:
> > 2009-apr-14 13:08:57 org.apache.commons.scxml.model.Log execute
> > INFO: Renegade: Entering state: A
> > 2009-apr-14 13:08:57 org.apache.commons.scxml.env.SimpleScheduler send
> > INFO: send ( sendId: 1, target: null, targetType: scxml, event: ToB,
> params:
> > null, hints: null, delay: 1000)
> >
> > best regards
> > //Linda
> >
>
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
>
>