You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Fabrizio Morbini <fm...@gmail.com> on 2010/06/03 02:08:30 UTC

[scxml] src and parser invocation

Hi, if we have the following case:
 2 scxml files: a.scxml and b.scxml
 in a.scxml, 2 different nodes use the src attribute to source the
content from other 2 different nodes defined in b.scxml (using the
syntax src="b.scxml#node_i").

is the file b.scxml completely parsed for every instance of src
attribute found while parsing a.scxml? Or is b.scxml parsed only once
and the result reused?

thanks,
fabrizio.

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


Re: [scxml] src and parser invocation

Posted by Rahul Akolkar <ra...@gmail.com>.
On Wed, Jun 2, 2010 at 8:39 PM, Fabrizio Morbini <fm...@gmail.com> wrote:
> Hi Rahul, (btw, thanks for your quick and precise answers.)
>
> is there anything wrong in modifying the methog:
> DigestSrcAttributeRule in SCXMLParser.java to add an
> HashMap<String,SCXML> that stores the result of the call
> "externalSrcDigester.parse(location);" for a given "location"?
> If the same "location" is encountered again, the previous result is reused.
>
<snip/>

That assumes the resource at the URL is a static one, whereas there is
no such limitation so it isn't cached by default. Obviously, if all
src'ed URLs are static in your case, that would certainly help to not
retrieve and parse them multiple times as you indicate above.


> i tried this and it works fine (no parse errors) and reduces the parse
> time from 90 seconds to less than a second. But i didn't try to
> execute the network and i'm afraid the produced network may have some
> subtle problems caused by reusing the result of the parser.
>
<snap/>

You may want to try executing it. There generally shouldn't be issues
unless you are src'ing in the same state (or entire state machine)
from the same external document multiple times in which case you can
run into ID clashes. There is a wiki page [1] that describes one
pattern to work around such clashes, but it involves dynamic resources
(so caching won't be a good option there).

-Rahul

[1] http://wiki.apache.org/commons/SCXML/Tutorials/Templating


> thanks,
> fabrizio.
>
> On Wed, Jun 2, 2010 at 17:18, Rahul Akolkar <ra...@gmail.com> wrote:
>> On Wed, Jun 2, 2010 at 8:08 PM, Fabrizio Morbini <fm...@gmail.com> wrote:
>>> Hi, if we have the following case:
>>>  2 scxml files: a.scxml and b.scxml
>>>  in a.scxml, 2 different nodes use the src attribute to source the
>>> content from other 2 different nodes defined in b.scxml (using the
>>> syntax src="b.scxml#node_i").
>>>
>>> is the file b.scxml completely parsed for every instance of src
>>> attribute found while parsing a.scxml? Or is b.scxml parsed only once
>>> and the result reused?
>>>
>> <snip/>
>>
>> It will be parsed twice, completely (any time the src attribute is
>> used, the entire document at the mentioned URL is parsed). Therefore,
>> where possible, its better to separate content that gets sourced in,
>> into smaller independent files.
>>
>> -Rahul
>>
>>
>>> thanks,
>>> fabrizio.
>>>

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


Re: [scxml] src and parser invocation

Posted by Fabrizio Morbini <fm...@gmail.com>.
Hi Rahul, (btw, thanks for your quick and precise answers.)

is there anything wrong in modifying the methog:
DigestSrcAttributeRule in SCXMLParser.java to add an
HashMap<String,SCXML> that stores the result of the call
"externalSrcDigester.parse(location);" for a given "location"?
If the same "location" is encountered again, the previous result is reused.

i tried this and it works fine (no parse errors) and reduces the parse
time from 90 seconds to less than a second. But i didn't try to
execute the network and i'm afraid the produced network may have some
subtle problems caused by reusing the result of the parser.

thanks,
fabrizio.

On Wed, Jun 2, 2010 at 17:18, Rahul Akolkar <ra...@gmail.com> wrote:
> On Wed, Jun 2, 2010 at 8:08 PM, Fabrizio Morbini <fm...@gmail.com> wrote:
>> Hi, if we have the following case:
>>  2 scxml files: a.scxml and b.scxml
>>  in a.scxml, 2 different nodes use the src attribute to source the
>> content from other 2 different nodes defined in b.scxml (using the
>> syntax src="b.scxml#node_i").
>>
>> is the file b.scxml completely parsed for every instance of src
>> attribute found while parsing a.scxml? Or is b.scxml parsed only once
>> and the result reused?
>>
> <snip/>
>
> It will be parsed twice, completely (any time the src attribute is
> used, the entire document at the mentioned URL is parsed). Therefore,
> where possible, its better to separate content that gets sourced in,
> into smaller independent files.
>
> -Rahul
>
>
>> thanks,
>> fabrizio.
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

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


Re: [scxml] src and parser invocation

Posted by Rahul Akolkar <ra...@gmail.com>.
On Wed, Jun 2, 2010 at 8:08 PM, Fabrizio Morbini <fm...@gmail.com> wrote:
> Hi, if we have the following case:
>  2 scxml files: a.scxml and b.scxml
>  in a.scxml, 2 different nodes use the src attribute to source the
> content from other 2 different nodes defined in b.scxml (using the
> syntax src="b.scxml#node_i").
>
> is the file b.scxml completely parsed for every instance of src
> attribute found while parsing a.scxml? Or is b.scxml parsed only once
> and the result reused?
>
<snip/>

It will be parsed twice, completely (any time the src attribute is
used, the entire document at the mentioned URL is parsed). Therefore,
where possible, its better to separate content that gets sourced in,
into smaller independent files.

-Rahul


> thanks,
> fabrizio.
>

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