commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fasihullah Askiri" <fasihullah.ask...@baypackets.com>
Subject RE: [scxml] adding an xml to the datamodel
Date Fri, 28 Apr 2006 16:33:56 GMT
Hi
You can see a loads of example on the net for digester usage. This is how you can do it.

public void process() {
	Digester digester = new Digester();
	digester.push(new TestDigester());
	digester.addRule("scenarios/scenario/junk", new NodeCreateRule());
	digester.addSetNext("scenarios/scenario/junk", "addJunk");
	digester.parse(TestDigester.class.getClassLoader()
			.getResourceAsStream("scenario.xml"));
}
public void addJunk(Element e) {
	Data d = new Data("name");
	d.setNode(e);
	getDocument().getDataModel().addData(data);
}


+Fasih
-----Original Message-----
From: Nestor Urquiza [mailto:nestoru@yahoo.com]
Sent: Fri 4/28/2006 8:26 AM
To: Jakarta Commons Users List
Subject: RE: [scxml] adding an xml to the datamodel
 
I have it parsed yes. But it is not a problem since
everything can be converted to InputStreams for
example.

In any case I am then interested in the code you have
for applying the rule. I see Datamodel#setNode()
method and i think it can be the solution but I do not
know how to use it.
Something like :
<pseudo>
datamodel.setNode(InputStream)
</pseudo>
would be a logical solution for example ... botton
line is the rule coded in the current commons-scxml
core/samples or it is code you made? and in any case
could you share it?
thanks!

--- Fasihullah Askiri
<fasihullah.askiri@baypackets.com> wrote:

> Do you have the external file as a file, I mean,
> have you parsed it? if not, you can get the digester
> to add the content. For e.g. this is what I do
> 
> scenario.xml
> ------------
> <my_data>
> <data include="yes" value="afdsdf"/>
> </my_data>
> 
> When I digest this file, I have a rule which puts it
> in the datamodel if it sees include=yes. You will
> notice that the content is still name,value pair and
> not an "XML" per se which you might use to do an
> Xpath query maybe.
> 
> +Fasih
> 
> 
> -----Original Message-----
> From: Nestor Urquiza [mailto:nestoru@yahoo.com]
> Sent: Fri 4/28/2006 7:34 AM
> To: Jakarta Commons Users List
> Subject: [scxml] adding an xml to the datamodel
>  
> 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.
> /* 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
> 
> __________________________________________________
> 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
> 
> 
> 
> 
> 
> >
---------------------------------------------------------------------
> 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