Search in sources :

Example 21 with IMicroElement

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);
    }
}
Also used : OpenAS2Exception(com.helger.as2lib.exception.OpenAS2Exception) IMicroElement(com.helger.xml.microdom.IMicroElement)

Example 22 with IMicroElement

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);
    }
}
Also used : IMicroElement(com.helger.xml.microdom.IMicroElement) IReadableResource(com.helger.commons.io.resource.IReadableResource) PSSchema(com.helger.schematron.pure.model.PSSchema) CollectingPSErrorHandler(com.helger.schematron.pure.errorhandler.CollectingPSErrorHandler) Test(org.junit.Test)

Example 23 with IMicroElement

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;
}
Also used : MicroElement(com.helger.xml.microdom.MicroElement) IMicroElement(com.helger.xml.microdom.IMicroElement) IMicroElement(com.helger.xml.microdom.IMicroElement) Nonnull(javax.annotation.Nonnull)

Example 24 with IMicroElement

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;
}
Also used : MicroElement(com.helger.xml.microdom.MicroElement) IMicroElement(com.helger.xml.microdom.IMicroElement) IMicroElement(com.helger.xml.microdom.IMicroElement) Nonnull(javax.annotation.Nonnull)

Example 25 with IMicroElement

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;
}
Also used : IMicroElement(com.helger.xml.microdom.IMicroElement) MicroElement(com.helger.xml.microdom.MicroElement) IMicroElement(com.helger.xml.microdom.IMicroElement) Nonnull(javax.annotation.Nonnull)

Aggregations

IMicroElement (com.helger.xml.microdom.IMicroElement)41 Nonnull (javax.annotation.Nonnull)30 MicroElement (com.helger.xml.microdom.MicroElement)18 IMicroDocument (com.helger.xml.microdom.IMicroDocument)7 OpenAS2Exception (com.helger.as2lib.exception.OpenAS2Exception)3 IReadableResource (com.helger.commons.io.resource.IReadableResource)3 File (java.io.File)3 CommandResult (com.helger.as2.cmd.CommandResult)2 XMLPartnershipFactory (com.helger.as2lib.partner.xml.XMLPartnershipFactory)2 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)2 IMicroNode (com.helger.xml.microdom.IMicroNode)2 MicroDocument (com.helger.xml.microdom.MicroDocument)2 Partnership (com.helger.as2lib.partner.Partnership)1 Partner (com.helger.as2lib.partner.xml.Partner)1 IMessageProcessor (com.helger.as2lib.processor.IMessageProcessor)1 ValueEnforcer (com.helger.commons.ValueEnforcer)1 Nonempty (com.helger.commons.annotation.Nonempty)1 ICommonsList (com.helger.commons.collection.impl.ICommonsList)1 DefaultHierarchyVisitorCallback (com.helger.commons.hierarchy.visit.DefaultHierarchyVisitorCallback)1 EHierarchyVisitorReturn (com.helger.commons.hierarchy.visit.EHierarchyVisitorReturn)1