Problem raising event in scxml - java

I'm having a problem with the following scxml code:
<?xml version="1.0" encoding="utf-8"?>
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initialstate="global">
...
<state id="global" initial="init">
...
<state id="state2">
<onentry>
<if cond="mydata.skip">
<if cond="_event.name=='ev.prev'">
<raise event="ev.prev" />
<else/>
<raise event="ev.next" />
</if>
</if>
</onentry>
<transition event="ev.next" target="end" />
<transition event="ev.prev" target="state1" />
</state>
...
</state>
</scxml>
It works ok but when I have added the onentry element the proccessor says the following:
[WARN] Ignoring element <raise> in namespace "http://www.w3.org/2005/07/scxml" at null:2:882 and digester match "scxml/state/state/onentry/if/if/raise"
[WARN] Ignoring element <raise> in namespace "http://www.w3.org/2005/07/scxml" at null:2:912 and digester match "scxml/state/state/onentry/if/if/else/raise"
It seems that raise is not understood. I've tried to change 'raise' element with the 'send' one and I've gotten a similar log warning. Can anyone tell me what may be wrong?
Thanks.
UPDATE
I've tried to change the schema avoiding the embedding of the if elements like this:
<?xml version="1.0" encoding="utf-8"?>
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initialstate="global">
...
<state id="global" initial="init">
...
<state id="state2">
<onentry>
<if cond="mydata.skip and _event.name=='ev.prev'">
<raise event="ev.prev" />
<else if cond="mydata.skip and _event.name=='ev.next'"/>
<raise event="ev.next" />
</if>
</onentry>
<transition event="ev.next" target="end" />
<transition event="ev.prev" target="state1" />
</state>
...
</state>
</scxml>
but it gives the following error too:
[WARN] Ignoring element <raise> in namespace "http://www.w3.org/2005/07/scxml" at null:2:1057 and digester match "scxml/state/state/onentry/if/raise"

I couldn't make the raise event work either. But according to the standard:
http://www.w3.org/TR/scxml/#raise
you can also use a send event. So I tried that, and I could make that work.
<state id="testID">
<onentry>
<send event="'test.onentry'" />
</onentry>
<transition event="test.transition" target="testID2"></transition>
</state>
That sent the event test.onentry as expected. But note the single quotes inside the double quotes in there!

Related

Add an node to an xml when the same node is present in the xml as an empty tag

<?xml version="1.0" encoding="UTF-8"?>
<RESPONSE>
<STATUS>
<SERVERTIME><![CDATA[15319123123262]]></SERVERTIME>
<TYPE><![CDATA[getData]]></TYPE>
<RESPONSE_VERSION><![CDATA[1]]></RESPONSE_VERSION>
<DATA_VERSION><![CDATA[1]]></DATA_VERSION>
<VALUE><![CDATA[1]]></VALUE>
<ERRORS />
<WARNINGS />
</STATUS>
<DATA>
<CONTENT RECORDID="f2e110aa8ca24aewq929d26b9fcf3108962">
<METARESOURCEPATH><![CDATA[sites/xyz/content/meta/INFORMATION/0/INF427/]]></METARESOURCEPATH>
<REVIEW_TIMESTAMP><![CDATA[2018-07-20 15:36:00 IST]]></REVIEW_TIMESTAMP>
<REVIEW_TIMESTAMP_MILLIS><![CDATA[1532081160000]]></REVIEW_TIMESTAMP_MILLIS>
<VIEWS>
<VIEW>
<NAME><![CDATA[xyz]]></NAME>
<REFERENCE_KEY><![CDATA[xyz]]></REFERENCE_KEY>
<GUID><![CDATA[6d024478feb441231661f163de62d6e]]></GUID>
<OBJECTID><![CDATA[001]]></OBJECTID>
<PARENTID />
<CHILDCOUNT><![CDATA[8]]></CHILDCOUNT>
</VIEW>
</VIEWS>
<CATEGORIES />
</CONTENT>
</DATA>
</RESPONSE>
I need to add an element to CATEGORIES WHICH IS OF THE FORMAT.
When ever i try to add a new category it does not accept it because it finds a duplicate categories tag. But when i try to remove that empty tag , that is also not accepted because getelementbyname only returns null for categories.
<CATEGORIES>
<CATEGORY>
<NAME><![CDATA[xyz]]></NAME>
<REFERENCE_KEY><![CDATA[xyz]]></REFERENCE_KEY>
<GUID><![CDATA[6d024478feb441231661f163de62d6e]]></GUID>
<OBJECTID><![CDATA[001]]></OBJECTID>
<PARENTID />
<CHILDCOUNT><![CDATA[8]]></CHILDCOUNT>
</CATEGORY>
</CATEGORIES>
How can this be done with max efficiency ?

Attribute already defined with incompatible format

I'm getting this error in my project, and I cannot for the life of me find where my navigationMode is getting defined twice.
Error:(707) Attribute "navigationMode" already defined with incompatible format.
The source of the error is this file:
/Users/temp/code/MyCoolProject/app/build/intermediates/res/merged/debug/values/values.xml
How is this file generated? I didn't write it.
Here it is defined in my:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="navigationMode">
<enum name="listMode" value="1" />
<enum name="normal" value="0" />
<enum name="tabMode" value="2" />
</attr>
</resources>
How can I get rid of this error?
Check your operations with action bar.

Use WIX feature element in wxi and wxs with same Id

I want to generate a MSI package which contains only one feature.
I have a wxi file which is generated automatically. I cannot change this process.
wxi file looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
<Include>
<!-- components -->
<Feature Id="DefaultFeature" Title="Main Feature" Level="1">
<ComponentRef Id="comp0" />
<ComponentRef Id="comp1" />
<ComponentRef Id="comp2" />
<ComponentRef Id="comp3" />
<ComponentRef Id="CleanupMainApplicationFolder" />
</Feature>
</Include>
I have a wxs file which I can change:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Product ...>
<!-- components -->
<?include bundle.wxi ?>
<UI/>
<FeatureRef Id="DefaultFeature">
<ComponentRef Id="comp999" />
</FeatureRef>
</Product>
</Wix>
When I compile the wxs to MSI package Light is stating this error:
error LGHT0095 : Multiple primary references were found for Feature 'DefaultFeature' in Product '{...}' and Product '{...}'.
How do I change my wxs file to add a component to the feature defined in wxi file?
Thanks in advance.
Use <ComponentGroup> in your include files instead of <Feature>. Then, define your features in one place, the main .wxs file with <Product> element.
For example, this is how include file might look:
<Fragment>
<Component Id="Comp1" Guid="{GUID-GOES-HERE}">
...
</Component>
<Component Id="Comp2" Guid="{GUID-GOES-HERE}">
...
</Component>
<Component Id="Comp3" Guid="{GUID-GOES-HERE}">
...
</Component>
<ComponentGroup Id="CG1">
<ComponentRef Id="Comp1"/>
<ComponentRef Id="Comp2"/>
<ComponentRef Id="Comp3"/>
</ComponentGroup>
</Fragment>
And the main product.wxs defines the feature, includes the component group in there and allows including more components:
<Feature Id="MainFeature" Title="..." Level="100">
<ComponentGroupRef Id="CG1"/>
<!-- More components can go here -->
<Component Id="..">
</Component>
</Feature>
Moreover, you can include wxs files instead of include, too. As long as the main wxs references at least one element from another wxs, the entire contents will be included.

Parsing xml property to ant-build.xml file

I have a xml file "versionreferance.xml". below is the coding
<?xml version="1.0" encoding="utf-8"?>
<!-- Update "revision" value to -1 when the next build is intended to have its revision as 0. This needs to be done for patch/release builds-->
<BuildVersions>
<property name="major" value="1" />
<property name="minor" value="0" />
<property name="patch" value="0" />
<property name="revision" value="93" />
</BuildVersions>
The other is my ant-build.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<project name="xmlproperty-demo" default="init">
<xmlproperty file="versionreferance.xml" collapseAttributes="true" />
<echo>Major : ${BuildVersions.major}</echo>
<echo>Minor : ${BuildVersions.minor}</echo>
<echo>Patch : ${BuildVersions.patch}</echo>
<echo>Revision : ${BuildVersions.revision}</echo>
</project>
I am not getting the value in the output.
I want to get the path path dynamically of versionReference.xml , which will be in different place than antbuild.xml
Development\Build\VersionReference.xml
Development\Src\JAAS API\antbuild.xml
It should be dynamically. I am able to get the values form below code. But it's not dynamic.
<?xml version="1.0" encoding="UTF-8"?>
<project name="xmlproperty-demo" default="init">
<xmlproperty file="C:\\Development\\Build\\versionreferance.xml" collapseAttributes="true" />
<echo>Major : ${BuildVersions.major}</echo>
<echo>Minor : ${BuildVersions.minor}</echo>
<echo>Patch : ${BuildVersions.patch}</echo>
<echo>Revision : ${BuildVersions.revision}</echo>
</project>
I want to get the values only in this format.
<?xml version="1.0" encoding="utf-8"?>
<!-- Update "revision" value to -1 when the next build is intended to have its revision as 0. This needs to be done for patch/release builds-->
<BuildVersions>
<property name="major" value="1" />
<property name="minor" value="0" />
<property name="patch" value="0" />
<property name="revision" value="93" />
</BuildVersions>
I highly recommend using the free, third-party XmlTask library:
build.xml
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask" />
<xmltask>
<fileset file="versionreferance.xml"/>
<copy path="/BuildVersions/property[#name = 'major']/#value" property="BuildVersions.major"/>
<copy path="/BuildVersions/property[#name = 'minor']/#value" property="BuildVersions.minor"/>
<copy path="/BuildVersions/property[#name = 'patch']/#value" property="BuildVersions.patch"/>
<copy path="/BuildVersions/property[#name = 'revision']/#value" property="BuildVersions.revision"/>
</xmltask>
<echo>Major : ${BuildVersions.major}</echo>
<echo>Minor : ${BuildVersions.minor}</echo>
<echo>Patch : ${BuildVersions.patch}</echo>
<echo>Revision : ${BuildVersions.revision}</echo>
Output
run:
[echo] Major : 1
[echo] Minor : 0
[echo] Patch : 0
[echo] Revision : 93
If you add <echoproperties/> after the <xmlproperty> line you should see the properties are loaded but not as you expect. They will be something like:
BuildVersions.property=,,,
BuildVersions.property.name=major,minor,patch,revision
BuildVersions.property.value=1,0,0,93
This is because the properties are based off the node names, and in your case you have four instances of a "property" child node that are not unique. Your best bet may be to change the xml such as:
<BuildVersions>
<major>1</major>
....
</BuildVersions>
When you say xmlproperty with collapseAttributes="true" on xml file, it will flatten nested elements.
Details: https://ant.apache.org/manual/Tasks/xmlproperty.html
So just saying ${BuildVersions.major} doesn't give or print value as 1. Since you have same named xml element 'prooerty' you won't be able to get single propertie's value
For eg, in your case ${BuildVersions.property.name} will print 'major,minor,patch,revision'
Either you can redesign your versionreferance.xml to respect xmlproperty to work . Or you can make it as property file & say <property file="your.properties.file"/> & access them as normal properties!
If VersionReference.xml is going to be exactly where you mentioned in your question corresponding to your antbuild.xml.
I would suggest you to change your Absolute Path (as mentioned in question) with "..\..\Build\VersionReference.xml" which corresponds to the basedir="." in your project
This should work fine.
And considering your string format requirement.
I think the default comma(,) seperated value can then be replaced by dot(.) or manipulated as per your requirement by the following syntax
<propertyregex property="propB"
input="${propA}"
regexp=","
replace="."
global="true" />
Please find more info on this link :
Replacing characters in Ant property
Hope this helps.

is it possible to access value bundle properties in web-flow context?

This is a part of my web-flow:
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"
parent="estatGeneral" start-state="a_cargar_info">
<attribute name="caption" value="consultaDeutesHandler.filAriadna" />
<action-state id="a_cargar_info">
<evaluate expression="consultaDeutesHandler.primeraCarrega(flowRequestContext, usuari)"></evaluate>
<transition on="success" to="v_formulariDeutesInici"/>
<transition on="error" to="error"/>
</action-state>
I would like to insert text from a properties bundle or backing bean into an attribute. I tried this:
<attribute name="caption" value="consultaDeutesHandler.filAriadna" />
where consultaDeutesHandler.filAriadna is a function that returns a String. Instead of the expected value I just see "consultaDeutesHandler.filAriadna" literally.
Is there a way to set the value of an attribute from a properties bundle?
The <attribute> tag will not work since it only supports plain strings, not EL expressions.
<set> should do the trick:
<set name="flowScope.caption" value="consultaDeutesHandler.filAriadna()" />
(Substitute requestScope, conversationScope, etc. for flowScope as appropriate.)
You can refer to this value later in the flow xml, and from your views. For a JSF example,
<div>#{caption}</div>
will ultimately contain the value returned from consultaDeutesHandler.filAriadna()

Categories

Resources