use of com.helger.xml.microdom.IMicroElement in project as2-server by phax.
the class XMLCommandRegistry method loadMultiCommand.
protected void loadMultiCommand(@Nonnull final IMicroElement aCommand, @Nullable final MultiCommand parent) throws OpenAS2Exception {
final MultiCommand cmd = new MultiCommand();
cmd.initDynamicComponent(getSession(), AS2XMLHelper.getAllAttrsWithLowercaseName(aCommand));
if (parent != null)
parent.getCommands().add(cmd);
else
addCommand(cmd);
for (final IMicroElement aChildElement : aCommand.getAllChildElements()) {
final String sChildName = aChildElement.getNodeName();
if (sChildName.equals("command"))
loadCommand(aChildElement, cmd);
else if (sChildName.equals("multicommand"))
loadMultiCommand(aChildElement, cmd);
else
throw new OpenAS2Exception("Undefined child tag: " + sChildName);
}
}
use of com.helger.xml.microdom.IMicroElement in project ph-schematron by phax.
the class PSReaderTest method testReadAll.
@Test
public void testReadAll() throws Exception {
for (final IReadableResource aRes : SchematronTestHelper.getAllValidSchematronFiles()) {
final PSReader aReader = new PSReader(aRes);
// Parse the schema
final PSSchema aSchema1 = aReader.readSchema();
assertNotNull(aSchema1);
final CollectingPSErrorHandler aLogger = new CollectingPSErrorHandler();
assertTrue(aRes.getPath(), aSchema1.isValid(aLogger));
assertTrue(aLogger.isEmpty());
// Convert back to XML
final IMicroElement e1 = aSchema1.getAsMicroElement();
final String sXML1 = MicroWriter.getNodeAsString(e1);
// Re-read the created XML and re-create it
final PSSchema aSchema2 = aReader.readSchemaFromXML(e1);
final IMicroElement e2 = aSchema2.getAsMicroElement();
final String sXML2 = MicroWriter.getNodeAsString(e2);
// Originally created XML and re-created-written XML must match
assertEquals(sXML1, sXML2);
}
}
use of com.helger.xml.microdom.IMicroElement in project ph-schematron by phax.
the class PSTitle method getAsMicroElement.
@Nonnull
public IMicroElement getAsMicroElement() {
final IMicroElement ret = new MicroElement(CSchematron.NAMESPACE_SCHEMATRON, CSchematronXML.ELEMENT_TITLE);
for (final Object aContent : m_aContent) if (aContent instanceof String)
ret.appendText((String) aContent);
else
ret.appendChild(((IPSElement) aContent).getAsMicroElement());
return ret;
}
use of com.helger.xml.microdom.IMicroElement in project ph-schematron by phax.
the class PSNS method getAsMicroElement.
@Nonnull
public IMicroElement getAsMicroElement() {
final IMicroElement ret = new MicroElement(CSchematron.NAMESPACE_SCHEMATRON, CSchematronXML.ELEMENT_NS);
ret.setAttribute(CSchematronXML.ATTR_PREFIX, m_sPrefix);
ret.setAttribute(CSchematronXML.ATTR_URI, m_sUri);
if (m_aForeignAttrs != null)
for (final Map.Entry<String, String> aEntry : m_aForeignAttrs.entrySet()) ret.setAttribute(aEntry.getKey(), aEntry.getValue());
return ret;
}
use of com.helger.xml.microdom.IMicroElement in project ph-schematron by phax.
the class PSParam method getAsMicroElement.
@Nonnull
public IMicroElement getAsMicroElement() {
final IMicroElement ret = new MicroElement(CSchematron.NAMESPACE_SCHEMATRON, CSchematronXML.ELEMENT_PARAM);
ret.setAttribute(CSchematronXML.ATTR_NAME, m_sName);
ret.setAttribute(CSchematronXML.ATTR_VALUE, m_sValue);
return ret;
}
Aggregations