commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nestor Urquiza <nest...@yahoo.com>
Subject Re: [scxml] adding an xml to the datamodel
Date Sun, 30 Apr 2006 00:48:20 GMT


--- Rahul Akolkar <rahul.akolkar@gmail.com> wrote:

> On 4/28/06, Nestor Urquiza <nestoru@yahoo.com>
> wrote:
> > Hello guys,
> > Here I am trying to include my external xml file
> into
> > the model using the snippet posted by Fasih:
> >
> > //byteArraySettingsFileContent has the external
> xml
> > file content
> > Data scenarioData = new Data();
> > //I need to understand how to set a node here with
> the
> > content of the above file.
> <snip/>
> 
> I have only glanced at this thread, maybe I missed
> something. You can
> obtain the org.w3.dom.Node instance whatever way you
> want and place it
> in the root context to achieve the same effect
> you're trying below. It
> doesn't have to be a <data> element (or Data class,
> if procedurally
> injected).

If I create the org.w3.dom.Node and I put the node
into a context variable foo, how can I access a
node/attribute using XPATH then?
Is something like
condition="foo/specificNode/@specificAttribute eq
'bar'" going to work?

> 
> The expression language evaluator doesn't know, nor
> does it care,
> where the "variable" came from -- whether it was a
> <var> / Var or
> <data> / Data or Context#setLocal() / set(), its all
> the same to the
> expression language.
> 
> Ofcourse, I need to write the data model section to
> the user guide so
> this is public knowledge. I'm out this weekend, if
> you want to post a
> ticket in bugzilla, it will be guaranteed to stay on
> our radar.
> 

Added Bug#:   	 39450

> There is one subtle difference between <var> and
> <data> with respect
> to the way an SCXMLExecutor instance resets itself.
> 
>  * <var>s being "scratch space" are deleted / lost
> on reset
> (Context#setLocal() / set() behaves the same way)
> 
>  * <data>s being part of the first class data model
> defined for a
> state, get reset to their initial value
> 
> But, the reset functionality is probably rarely used
> (and should be
> used with quite a bit of caution).
> 

Cool, in any case for some reason Data() is not
working for me when I insert a node using Digester.
Below my code that follows the reccomendations given
by Fasih:
(bSettingsFileContent  is a byte array with the
contents of my settings.xml file)

................

Digester digester = new Digester();
            digester.push( this );
            digester.addRule("datamodel", new
NodeCreateRule());
            digester.addSetNext("datamodel",
"addDataToModel");
            digester.parse(new ByteArrayInputStream(
bSettingsFileContent ));

...................

public void addDataToModel(Element e) {
     Data d = new Data();
     d.setNode(e);
     this.scxml.getDatamodel().addData(d);
  }

The node is inserted in the datamodel as I see while
debugging, however given the settings.xml file:

<datamodel>
	<data name="bubp">
		<root>
			<bubp>
				<client clientId="mk1" clientPswd="passmk1"
appType="SP">


the following does not work from my scxml file:

<n:if cond="Data('bubp', 'root/bubp/client/@appType')
eq 'SP'">

It does not work either if I put <bubp> as the root
node in my settings.xml file

Thanks!

> -Rahul
> 
> 
> > /* The Fasih sippet was for setting up String
> > variables:
> > scenarioData.setName(Constants.SCENARIO_ID_PARAM);
> > scenarioData.setExpr("the content of the var
> here");
> >
> > scxml.setDatamodel(new Datamodel());
> > scxml.getDatamodel().addData(scenarioData);
> >
> > Thanks you all,
> > Nestor
> >
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-user-help@jakarta.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Mime
View raw message