Java Code Examples for com.helger.xml.microdom.IMicroElement#appendChild()

The following examples show how to use com.helger.xml.microdom.IMicroElement#appendChild() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PSPhase.java    From ph-schematron with Apache License 2.0 6 votes vote down vote up
@Nonnull
public IMicroElement getAsMicroElement ()
{
  final IMicroElement ret = new MicroElement (CSchematron.NAMESPACE_SCHEMATRON, CSchematronXML.ELEMENT_PHASE);
  ret.setAttribute (CSchematronXML.ATTR_ID, m_sID);
  if (m_aRich != null)
    m_aRich.fillMicroElement (ret);
  for (final Object aContent : m_aContent)
    if (aContent instanceof IMicroElement)
      ret.appendChild (((IMicroElement) aContent).getClone ());
    else
      ret.appendChild (((IPSElement) aContent).getAsMicroElement ());
  if (m_aForeignAttrs != null)
    for (final Map.Entry <String, String> aEntry : m_aForeignAttrs.entrySet ())
      ret.setAttribute (aEntry.getKey (), aEntry.getValue ());
  return ret;
}
 
Example 2
Source File: PSP.java    From ph-schematron with Apache License 2.0 6 votes vote down vote up
@Nonnull
public IMicroElement getAsMicroElement ()
{
  final IMicroElement ret = new MicroElement (CSchematron.NAMESPACE_SCHEMATRON, CSchematronXML.ELEMENT_P);
  ret.setAttribute (CSchematronXML.ATTR_ID, m_sID);
  ret.setAttribute (CSchematronXML.ATTR_CLASS, m_sClass);
  ret.setAttribute (CSchematronXML.ATTR_ICON, m_sIcon);
  for (final Object aContent : m_aContent)
    if (aContent instanceof IMicroElement)
      ret.appendChild (((IMicroElement) aContent).getClone ());
    else
      if (aContent instanceof String)
        ret.appendText ((String) aContent);
      else
        ret.appendChild (((IPSElement) aContent).getAsMicroElement ());
  if (m_aForeignAttrs != null)
    for (final Map.Entry <String, String> aEntry : m_aForeignAttrs.entrySet ())
      ret.setAttribute (aEntry.getKey (), aEntry.getValue ());
  return ret;
}
 
Example 3
Source File: PSPattern.java    From ph-schematron with Apache License 2.0 6 votes vote down vote up
@Nonnull
public IMicroElement getAsMicroElement ()
{
  final IMicroElement ret = new MicroElement (CSchematron.NAMESPACE_SCHEMATRON, CSchematronXML.ELEMENT_PATTERN);
  if (m_bAbstract)
    ret.setAttribute (CSchematronXML.ATTR_ABSTRACT, "true");
  ret.setAttribute (CSchematronXML.ATTR_ID, m_sID);
  ret.setAttribute (CSchematronXML.ATTR_IS_A, m_sIsA);
  if (m_aRich != null)
    m_aRich.fillMicroElement (ret);
  for (final Object aContent : m_aContent)
    if (aContent instanceof IMicroElement)
      ret.appendChild (((IMicroElement) aContent).getClone ());
    else
      ret.appendChild (((IPSElement) aContent).getAsMicroElement ());
  if (m_aForeignAttrs != null)
    for (final Map.Entry <String, String> aEntry : m_aForeignAttrs.entrySet ())
      ret.setAttribute (aEntry.getKey (), aEntry.getValue ());
  return ret;
}
 
Example 4
Source File: PSDiagnostic.java    From ph-schematron with Apache License 2.0 6 votes vote down vote up
@Nonnull
public IMicroElement getAsMicroElement ()
{
  final IMicroElement ret = new MicroElement (CSchematron.NAMESPACE_SCHEMATRON, CSchematronXML.ELEMENT_DIAGNOSTIC);
  ret.setAttribute (CSchematronXML.ATTR_ID, m_sID);
  if (m_aRich != null)
    m_aRich.fillMicroElement (ret);
  for (final Object aContent : m_aContent)
    if (aContent instanceof IMicroElement)
      ret.appendChild (((IMicroElement) aContent).getClone ());
    else
      if (aContent instanceof String)
        ret.appendText ((String) aContent);
      else
        ret.appendChild (((IPSElement) aContent).getAsMicroElement ());
  if (m_aForeignAttrs != null)
    for (final Map.Entry <String, String> aEntry : m_aForeignAttrs.entrySet ())
      ret.setAttribute (aEntry.getKey (), aEntry.getValue ());
  return ret;
}
 
Example 5
Source File: PSActive.java    From ph-schematron with Apache License 2.0 6 votes vote down vote up
@Nonnull
public IMicroElement getAsMicroElement ()
{
  final IMicroElement ret = new MicroElement (CSchematron.NAMESPACE_SCHEMATRON, CSchematronXML.ELEMENT_ACTIVE);
  ret.setAttribute (CSchematronXML.ATTR_PATTERN, m_sPattern);
  for (final Object aContent : m_aContent)
    if (aContent instanceof IMicroElement)
      ret.appendChild (((IMicroElement) aContent).getClone ());
    else
      if (aContent instanceof String)
        ret.appendText ((String) aContent);
      else
        ret.appendChild (((IPSElement) aContent).getAsMicroElement ());
  if (m_aForeignAttrs != null)
    for (final Map.Entry <String, String> aEntry : m_aForeignAttrs.entrySet ())
      ret.setAttribute (aEntry.getKey (), aEntry.getValue ());
  return ret;
}
 
Example 6
Source File: PSRule.java    From ph-schematron with Apache License 2.0 6 votes vote down vote up
@Nonnull
public IMicroElement getAsMicroElement ()
{
  final IMicroElement ret = new MicroElement (CSchematron.NAMESPACE_SCHEMATRON, CSchematronXML.ELEMENT_RULE);
  ret.setAttribute (CSchematronXML.ATTR_FLAG, m_sFlag);
  if (m_bAbstract)
    ret.setAttribute (CSchematronXML.ATTR_ABSTRACT, "true");
  ret.setAttribute (CSchematronXML.ATTR_CONTEXT, m_sContext);
  ret.setAttribute (CSchematronXML.ATTR_ID, m_sID);
  if (m_aRich != null)
    m_aRich.fillMicroElement (ret);
  if (m_aLinkable != null)
    m_aLinkable.fillMicroElement (ret);
  for (final Object aContent : m_aContent)
    if (aContent instanceof IMicroElement)
      ret.appendChild (((IMicroElement) aContent).getClone ());
    else
      ret.appendChild (((IPSElement) aContent).getAsMicroElement ());
  if (m_aForeignAttrs != null)
    for (final Map.Entry <String, String> aEntry : m_aForeignAttrs.entrySet ())
      ret.setAttribute (aEntry.getKey (), aEntry.getValue ());
  return ret;
}
 
Example 7
Source File: PSDir.java    From ph-schematron with Apache License 2.0 6 votes vote down vote up
@Nonnull
public IMicroElement getAsMicroElement ()
{
  final IMicroElement ret = new MicroElement (CSchematron.NAMESPACE_SCHEMATRON, CSchematronXML.ELEMENT_DIR);
  if (m_eValue != null)
    ret.setAttribute (CSchematronXML.ATTR_VALUE, m_eValue.getID ());
  for (final Object aContent : m_aContent)
    if (aContent instanceof IMicroElement)
      ret.appendChild (((IMicroElement) aContent).getClone ());
    else
      ret.appendText ((String) aContent);
  if (m_aForeignAttrs != null)
    for (final Map.Entry <String, String> aEntry : m_aForeignAttrs.entrySet ())
      ret.setAttribute (aEntry.getKey (), aEntry.getValue ());
  return ret;
}
 
Example 8
Source File: ThreadDescriptorList.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
public IMicroElement getAsMicroNode ()
{
  final IMicroElement eRet = new MicroElement ("threadlist");
  if (StringHelper.hasText (m_sError))
    eRet.appendElement ("error").appendText (m_sError);

  // Overall thread count
  eRet.setAttribute ("threadcount", m_aList.size ());

  // Emit thread IDs grouped by state
  final ICommonsMap <State, ICommonsNavigableSet <Long>> aStateMap = _getStateMap ();
  for (final State eState : State.values ())
  {
    final ICommonsSet <Long> aThreadIDs = aStateMap.get (eState);
    final int nSize = aThreadIDs.size ();

    final IMicroElement eThreadState = eRet.appendElement ("threadstate");
    eThreadState.setAttribute ("id", eState.toString ());
    eThreadState.setAttribute ("threadcount", nSize);
    if (nSize > 0)
      eThreadState.appendText (StringHelper.getImploded (',', aThreadIDs));
  }

  // Append all stack traces at the end
  for (final ThreadDescriptor aDescriptor : m_aList)
    eRet.appendChild (aDescriptor.getAsMicroNode ());
  return eRet;
}
 
Example 9
Source File: AbstractMapBasedWALDAO.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
@MustBeLocked (ELockType.READ)
protected IMicroDocument createWriteData ()
{
  final IMicroDocument aDoc = new MicroDocument ();
  final IMicroElement eRoot = aDoc.appendElement (ELEMENT_ROOT);
  for (final IMPLTYPE aItem : internalGetAllSortedByKey ())
    eRoot.appendChild (MicroTypeConverter.convertToMicroElement (aItem, ELEMENT_ITEM));
  return aDoc;
}
 
Example 10
Source File: PSSpan.java    From ph-schematron with Apache License 2.0 5 votes vote down vote up
@Nonnull
public IMicroElement getAsMicroElement ()
{
  final IMicroElement ret = new MicroElement (CSchematron.NAMESPACE_SCHEMATRON, CSchematronXML.ELEMENT_SPAN);
  ret.setAttribute (CSchematronXML.ATTR_CLASS, m_sClass);
  for (final Object aContent : m_aContent)
    if (aContent instanceof IMicroElement)
      ret.appendChild (((IMicroElement) aContent).getClone ());
    else
      ret.appendText ((String) aContent);
  if (m_aForeignAttrs != null)
    for (final Map.Entry <String, String> aEntry : m_aForeignAttrs.entrySet ())
      ret.setAttribute (aEntry.getKey (), aEntry.getValue ());
  return ret;
}
 
Example 11
Source File: PSAssertReport.java    From ph-schematron with Apache License 2.0 5 votes vote down vote up
@Nonnull
public IMicroElement getAsMicroElement ()
{
  final IMicroElement ret = new MicroElement (CSchematron.NAMESPACE_SCHEMATRON,
                                              m_bIsAssert ? CSchematronXML.ELEMENT_ASSERT
                                                          : CSchematronXML.ELEMENT_REPORT);
  ret.setAttribute (CSchematronXML.ATTR_ID, m_sID);
  ret.setAttribute (CSchematronXML.ATTR_FLAG, m_sFlag);
  ret.setAttribute (CSchematronXML.ATTR_TEST, m_sTest);
  if (CollectionHelper.isNotEmpty (m_aDiagnostics))
    ret.setAttribute (CSchematronXML.ATTR_DIAGNOSTICS, StringHelper.getImploded (' ', m_aDiagnostics));
  if (m_aRich != null)
    m_aRich.fillMicroElement (ret);
  if (m_aLinkable != null)
    m_aLinkable.fillMicroElement (ret);
  for (final Object aContent : m_aContent)
    if (aContent instanceof IMicroElement)
      ret.appendChild (((IMicroElement) aContent).getClone ());
    else
      if (aContent instanceof String)
        ret.appendText ((String) aContent);
      else
        ret.appendChild (((IPSElement) aContent).getAsMicroElement ());
  if (m_aForeignAttrs != null)
    for (final Map.Entry <String, String> aEntry : m_aForeignAttrs.entrySet ())
      ret.setAttribute (aEntry.getKey (), aEntry.getValue ());
  return ret;
}
 
Example 12
Source File: PSTitle.java    From ph-schematron with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 13
Source File: PSDiagnostics.java    From ph-schematron with Apache License 2.0 5 votes vote down vote up
@Nonnull
public IMicroElement getAsMicroElement ()
{
  final IMicroElement ret = new MicroElement (CSchematron.NAMESPACE_SCHEMATRON, CSchematronXML.ELEMENT_DIAGNOSTICS);
  for (final Object aContent : m_aContent)
    if (aContent instanceof IMicroElement)
      ret.appendChild (((IMicroElement) aContent).getClone ());
    else
      ret.appendChild (((IPSElement) aContent).getAsMicroElement ());
  if (m_aForeignAttrs != null)
    for (final Map.Entry <String, String> aEntry : m_aForeignAttrs.entrySet ())
      ret.setAttribute (aEntry.getKey (), aEntry.getValue ());
  return ret;
}
 
Example 14
Source File: MicroTypeConverterTreeXML.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
public void appendDataValue (@Nonnull final IMicroElement eDataElement, @Nullable final DATATYPE aObject)
{
  // Append created element - or null if the passed object is null
  final IMicroElement eElement = MicroTypeConverter.convertToMicroElement (aObject, m_sNamespaceURI, m_sElementName);
  eDataElement.appendChild (eElement);
}