Actionscript 3 aaa namespace gets added - actionscript

The following code results in nodes with "aaa" injected as the namespace. What is the correct way to convert from a ICollectionView to an XMLList without injecting a namespace?
The conversion to XMLList seems to create a default namespace called "aaa". This code is inside of a class that extends DefaultDataDescriptor.
I have this declaration at the top of this class, to be honest, I'm not sure why or when I added it, I still find namepsaces to be confusing:
var xns:Namespace = new Namespace("http://www.spicefactory.org/parsley");
I've already tried removeNamespace() on the XMLList, which didn't seem to have any effect. Thanks!
var x:XML =
<property xmlns="http://www.spicefactory.org/parsley" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="steps">
<array>
<object type="com.tn.assistant.models.Step">
<property name="id" value="2"/>
<property name="name" value="outro"/>
</object>
</array>
</property>
var chICollView:ICollectionView = getChildren(x);
var chXMList:XMLList = XMLList (chICollView);
Resulting XMLList, chXMLList =
<aaa:object type="com.tn.assistant.models.Step" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aaa="http://www.spicefactory.org/parsley">
<aaa:property name="id" value="2"/>
<aaa:property name="name" value="outro"/>
</aaa:object>

Added this in my constructor, and it fixed it:
default xml namespace = xns;

Related

How can one register a Direct2D custom effect that has variable numbers of inputs?

I am making custom effects with Direct2D, based on Microsoft Learn page. The problem is that, I wanted to make a Direct2D effect which support a variable input count, like Direct2D Composite Effect, while the XML registration string used for ID2D1Factory1::RegisterEffectFromString seemed to take fixed <Input> properties. What should be done in XML registration string?
My XML is almost the same as one from Microsoft Learn page. Still I will provide mine.
auto xml_AxisRotation = XML(
<?xml version='1.0'?>
<Effect>
<!--System Properties-->
<Property name='DisplayName' type='string' value='MultiInput Effect'/>
<Property name='Author' type='string' value='Nan_ok'/>
<Property name='Category' type='string' value='None'/>
<Property name='Description' type='string' value='asdfasdfasdf'/>
<Inputs>
<Input name='Source1'/>
<Input name='Source2'/>
//...?
</Inputs>
<!--Custom Properties go here-->
<Property name='Mode' type='int32'>
<Property name='DisplayName' type='string' value='Mode'/>
<Property name='Default' type='int32' value='1'/>
</Property>
</Effect>
);
I once deliberately omitted the whole <Input> part, but it failed to perform; E_INVALIDARG has been returned.
The XML registration and actual Direct2D effect's input taking worked differently. By proper implementing ID2D1EffectImpl::SetGraph and calling ID2D1Effect::SetInputCount, I was able to set variable numbers of target.
It seemed ok to leave <Inputs> with no <Input> property. here is my XML example.
auto xml_AxisRotation = XML(
<?xml version='1.0'?>
<Effect>
<!--System Properties-->
<Property name='DisplayName' type='string' value='MultiInput Effect'/>
<Property name='Author' type='string' value='Nan_o'/>
<Property name='Category' type='string' value='None'/>
<Property name='Description' type='string' value='asdfasdfasdf'/>
<Inputs> </Inputs> <!--Leaving like this is ok-->
<!--Custom Properties go here-->
<Property name='Mode' type='int32'>
<Property name='DisplayName' type='string' value='Mode'/>
<Property name='Default' type='int32' value='1'/>
</Property>
</Effect>
);

ANT Build: Can the token itself be parsed from other values from within the property file?

Can the token itself be parsed from other values from within the property file?
Is it possible to evaluate the token key, without hardcoding the token? Can the token itself be parsed from other values from within the property file?
For example, if the properties file has the following tokens (test.properties):
module_no = 01
module_code = bb
title_01_aa = ABC
title_02_aa = DEF
title_03_aa = GHI
title_01_bb = JKL
title_02_bb = MNO
title_03_bb = PQR
Contents of build.xml
<?xml version="1.0" encoding="utf-8"?>
<project default="repl">
<property file="test.properties" />
<target name="repl">
<replace file="test.txt" token="module_title" value="title_${module_no}_${module_code}" />
</target>
</project>
Sample content with text:
Welcome to module_title.
The replace task will result in:
Welcome to title_01_bb.
How to achieve this instead?
Welcome to JKL.
This might be very basic, but please do guide me in the right direction. Thank you.
Nested property expansion does not work by default in Ant as described in the documentation:
Nesting of Braces
In its default configuration Ant will not try to balance braces in property expansions, it will only consume the text up to the first closing brace when creating a property name. I.e. when expanding something like ${a${b}} it will be translated into two parts:
the expansion of property a${b - likely nothing useful.
the literal text } resulting from the second closing brace
This means you can't use easily expand properties whose names are given by properties, but there are some workarounds for older versions of Ant. With Ant 1.8.0 and the the props Antlib you can configure Ant to use the NestedPropertyExpander defined there if you need such a feature.
If you check the workarounds link, one solution is to use a macrodef to copy the property:
<property file="test.properties" />
<target name="repl">
<gettitleprop name="titleprop" moduleno="${module_no}" modulecode="${module_code}" />
<replace file="test.txt" token="module_title" value="${titleprop}" />
</target>
<macrodef name="gettitleprop">
<attribute name="name"/>
<attribute name="moduleno"/>
<attribute name="modulecode"/>
<sequential>
<property name="#{name}" value="${title_#{moduleno}_#{modulecode}}"/>
</sequential>
</macrodef>

Grails Constraints with Java Classes and Hibernate Mappings

I have the following Java class defined in src/java
package org.davisworld.trip;
public class AirportHbm {
private long id;
private String name;
private String iata;
private String state;
private String lat;
private String lng;
// getters/setters defined
}
I have the hbm.cfg.xml file defined as follows in conf/hibernate:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<mapping resource="AirportHbm.hbm.xml"/>
</session-factory>
</hibernate-configuration>
I have the AirportHbm.hbm.xml file configured as follows in conf/hibernate:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="org.davisworld.trip.AirportHbm" table="usgs_airports">
<id name="id" column="airport_id">
<generator class="native"/>
</id>
<property name="name" type="java.lang.String">
<column name="airport_name" not-null="true" />
</property>
<property name="iata" type="java.lang.String">
<column name="locid" not-null="true" />
</property>
<property name="state" />
<property name="lat" column="latitude" />
<property name="lng" column="longitude" />
</class>
</hibernate-mapping>
And lastly, I have an AirportHbmConstraints.groovy file in the src/java folder:
package org.davisworld.trip
class AirportHbmConstraints {
static constraints = {
name()
iata(maxSize:3)
state(maxSize:2)
lat()
lng()
}
}
When I try to run the app, I get this error when Spring is initializing the web app context:
Caused by: java.lang.ClassCastException: org.davisworld.trip.AirportHbmConstraints cannot be cast to groovy.lang.Script
The tutorial I was following originally said that the AirportHbmConstraints.groovy file shouldn't have a class; it should just be a script:
package org.davisworld.trip
static constraints = {
name()
iata(maxSize:3)
state(maxSize:2)
lat()
lng()
}
But when I do that, STS gives me a compiler error:
Groovy:Modifier 'static' not allowed here.
Anyone know what I'm doing wrong? What is the correct way to apply constraints in Groovy to a Java domain class?
Many thanks,
Vito
When using constraints scripts with a Hibernate domain you do not use a class declaration or the static modifier as explained in section 15.3 Adding Constraints of the Grails documentation.
The correct constraint script would be:
constraints = {
iata maxSize: 3
state maxSize: 2
}
Note that fields without a constraint and the parentheses on the field declaration are optional.

Spring Framework basics

I'm quite new to Spring Framework. Could someone please help me understand the spring configuration below?
<?xml version="1.0"?>
<configuration>
<spring>
<context>
<resource uri="config://spring/objects" />
</context>
<objects xmlns="http://www.springframework.net">
<object type="Test.aspx">
<property name="AService" ref="AService" />
<property name="BService" ref="BService" />
</object>
</objects>
</spring>
</configuration>
Basically questions in my mind are:
What does this line means:
<resource uri="config://spring/objects" />
and this:
<object type="Test.aspx">
<property name="AService" ref="AService" />
<property name="BService" ref="BService" />
</object>
Does config: means configuration file?
Does ref means Classes in C#?
<resource uri="config://spring/objects" /> means that the spring container should read a configuration section from an application configuration file (app.config or web.config).
<object ... is an object definition; this defines an object in your container. An object can have dependencies. In your case, the Test.aspx page has properties named AService and BService. The container will set these properties to the objects defined elsewhere in your container.
What might be a bit confusing here is the double usage of ="AService" in <property name="AService" ref="AService" />:
name=: refers to the name of the property on your class Test, there is a property defined as public IMyService AService { get; set; }
ref= : refers to another object defined in your container, there is an object definition like <object id="AService" type="MyNamespace.MyClass, MyAssembly" /> somewhere in your configuration.
The "Instantiating the container" section of the spring docs does a good job of explaining this further.

Spring.NET problem with <idref> tag in config

According to the help file that comes with the Spring.NET framework, you can inject a dependancy defined in the local file by using an 'idref' tag along with a 'local' attribute.
I have been trying to do this with no success and was hoping someone had the experience to help me out.
Below I have a snippet from the config where I am passing it as a constructor argument, but I have tried setting it as a property as well. Both methods seem to yield the same error.
<object id="theTargetObject" type="TestClassLibrary.TargetObject, TestClassLibrary"/>
<object id="theClientObject" type="TestClassLibrary.ClientObject, TestClassLibrary">
<constructor-arg name="myClass">
<idref local="theTargetObject"/>
</constructor-arg>
</object>
Error creating context 'spring.root': Error creating object with name 'theClientObject' defined in 'file [C:\Test\TestApp\bin\Debug\my.config.xml]' : Unsatisfied dependency expressed through constructor argument with index 0 of type [TestClassLibrary.TargetObject] : Could not convert constructor argument value [theTargetObject] to required type [TestClassLibrary.TargetObject] : Cannot convert property value of type [System.String] to required type [TestClassLibrary.TargetObject] for property ''.
I guess gef was on the right way but accidentially mixed it up when pasting the snippet.You are looking for the <ref> element:
<object id="theTargetObject" type="TestClassLibrary.TargetObject, TestClassLibrary"/>
<object id="theClientObject" type="TestClassLibrary.ClientObject, TestClassLibrary">
<property name="myClass">
<ref local="theTargetObject"/>
</property>
the shorthand notation for this is:
<object id="theClientObject" type="TestClassLibrary.ClientObject, TestClassLibrary">
<property name="myClass ref="theTargetObject"/>
hth,
Erich
Please view the post http://forum.springsource.org/showthread.php?t=14211

Resources