use of org.whole.lang.xml.factories.XmlEntityFactory in project whole by wholeplatform.
the class ByChildAPITest method testAbstractUListEntity.
@Test
public void testAbstractUListEntity() {
XmlEntityFactory xmlf = XmlEntityFactory.instance(RegistryConfigurations.STRICT);
Attribute a1 = xmlf.createAttribute(xmlf.createName("attr1"), xmlf.createValue("value1"));
Attribute a2 = xmlf.createAttribute(xmlf.createName("attr2"), xmlf.createValue("value2"));
Attribute a3 = xmlf.createAttribute(xmlf.createName("attr3"), xmlf.createValue("value3"));
Attribute[] attributesArray = new Attribute[] { a1, a2, a3 };
int[] businessEquivalence = new int[] { 0, 1, 2 };
Attributes attributes = xmlf.createAttributes(attributesArray);
orderedCompositeOperationsEntityTest(attributesArray, businessEquivalence, attributes);
commonOperationsEntityTest(attributesArray, attributesArray, attributes);
uniqueOperationsEntityTest(attributesArray, attributes);
propertyChangeEntityTest(attributesArray, attributes, xmlf.createAttribute(xmlf.createName("attr4"), xmlf.createValue("value4")));
}
use of org.whole.lang.xml.factories.XmlEntityFactory in project whole by wholeplatform.
the class NormalizerOperationTest method testXmlBehavior.
@Test
public void testXmlBehavior() {
assertTrue(ReflectionFactory.getLanguageKit(XmlLanguageKit.URI).hasVisitor(NormalizerOperation.ID));
XmlEntityFactory ef = XmlEntityFactory.instance;
CDataSect data = ef.createCDataSect(ef.createCDataSectData("one"), ef.createCDataSectData("two"), ef.createCDataSectData("three"));
CDataSect dataOrig = EntityUtils.clone(data);
NormalizerOperation.normalize(data);
assertFalse(Matcher.match(dataOrig, data));
CDataSect dataOrig2 = EntityUtils.clone(data);
NormalizerOperation.normalize(data);
assertTrue(Matcher.match(dataOrig2, data));
}
use of org.whole.lang.xml.factories.XmlEntityFactory in project whole by wholeplatform.
the class XmlSpecific2XsiBuilderAdapter method normalizeXmlFragment.
protected org.whole.lang.xml.model.Element normalizeXmlFragment(org.whole.lang.xml.model.Element xmlFragment) {
XmlFragmentNormalizer normalizer = new XmlFragmentNormalizer(true);
xmlFragment.accept(normalizer);
// add needed namespace declarations
XmlEntityFactory xef = XmlEntityFactory.instance;
IEntity attributes = xmlFragment.getAttributes();
for (String prefix : normalizer.getNeededNamespaces()) attributes.wAdd(xef.createAttribute(xef.createQualifiedName(xef.createNameSpace("xmlns"), xef.createName(prefix)), xef.createValue(ns.wStringValue(prefix))));
return xmlFragment;
}
use of org.whole.lang.xml.factories.XmlEntityFactory in project whole by wholeplatform.
the class GrammarsUtilsTest method testUnparseXmlElement.
@Test
public void testUnparseXmlElement() {
XmlEntityFactory xf = XmlEntityFactory.instance;
Element e = xf.createElement(xf.createQualifiedName(xf.createNameSpace("ns"), xf.createName("tag")), xf.createAttributes(xf.createAttribute(xf.createName("attr"), xf.createValue("val")), xf.createAttribute(xf.createName("attr2"), xf.createValue("val2"))), xf.createCharData("test"));
StringBuilder sb = new StringBuilder();
GrammarsUtils.unparse(e, sb, xmlGrammarURI);
Assert.assertEquals("<ns:tag attr=\"val\" attr2=\"val2\">test</ns:tag>", sb.toString());
}
Aggregations