com.helger.xml.microdom.MicroElement Java Examples

The following examples show how to use com.helger.xml.microdom.MicroElement. 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: 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 #2
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 #3
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 #4
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 #5
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 #6
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 #7
Source File: SettingsMicroDocumentConverter.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
@Nonnull
public IMicroElement convertToMicroElement (@Nonnull final T aObject,
                                            @Nullable final String sNamespaceURI,
                                            @Nonnull final String sTagName)
{
  final IMicroElement eRoot = new MicroElement (sNamespaceURI, sTagName);
  eRoot.setAttribute (ATTR_NAME, aObject.getName ());

  // Sort fields to have them deterministic
  for (final Map.Entry <String, Object> aEntry : aObject.getSortedByKey (Comparator.naturalOrder ()).entrySet ())
  {
    final String sFieldName = aEntry.getKey ();
    final Object aValue = aEntry.getValue ();

    final IMicroElement eSetting = eRoot.appendElement (sNamespaceURI, ELEMENT_SETTING);
    eSetting.setAttribute (ATTR_NAME, sFieldName);
    if (aValue == null)
      eSetting.setAttribute (ATTR_IS_NULL, true);
    else
    {
      final String sValue = TypeConverter.convert (aValue, String.class);
      eSetting.appendText (sValue);
    }
  }
  return eRoot;
}
 
Example #8
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 #9
Source File: MicroHelperTest.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetChildTextContentWithConversionAndNS ()
{
  final String sNSURI = "my-namespace-uri";
  final IMicroElement e = new MicroElement (sNSURI, "x");
  assertNull (MicroHelper.getChildTextContentWithConversion (e, sNSURI, "y", BigInteger.class));
  final IMicroElement y = e.appendElement (sNSURI, "y");
  assertNull (MicroHelper.getChildTextContentWithConversion (e, sNSURI, "y", BigInteger.class));
  y.appendText ("100");
  assertEquals (CGlobal.BIGINT_100, MicroHelper.getChildTextContentWithConversion (e, sNSURI, "y", BigInteger.class));
  y.appendElement ("a");
  assertEquals (CGlobal.BIGINT_100, MicroHelper.getChildTextContentWithConversion (e, sNSURI, "y", BigInteger.class));
  y.appendCDATA ("234");
  assertEquals (BigInteger.valueOf (100234),
                MicroHelper.getChildTextContentWithConversion (e, sNSURI, "y", BigInteger.class));
}
 
Example #10
Source File: MicroWriterTest.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
@Test
public void testOrderAttributes ()
{
  XMLWriterSettings aSettings = new XMLWriterSettings ().setIndent (EXMLSerializeIndent.NONE)
                                                        .setUseDoubleQuotesForAttributes (false);

  // default order
  final IMicroElement e = new MicroElement ("a");
  e.setAttribute ("c", "1");
  e.setAttribute ("b", "2");
  e.setAttribute ("a", "3");
  assertEquals ("<a c='1' b='2' a='3' />", MicroWriter.getNodeAsString (e, aSettings));

  // Lexicographic order
  aSettings = aSettings.setOrderAttributesAndNamespaces (true);
  assertEquals ("<a a='3' b='2' c='1' />", MicroWriter.getNodeAsString (e, aSettings));
}
 
Example #11
Source File: MicroWriterTest.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetXHTMLString ()
{
  final IMicroDocument aDoc = MicroReader.readMicroXML (TEST_XML);
  _testGetNodeAsXHTMLString (aDoc);
  _testGetNodeAsXHTMLString (aDoc.getDocumentElement ());
  _testGetNodeAsXHTMLString (new MicroDocument ());
  _testGetNodeAsXHTMLString (new MicroElement ("xyz"));
  _testGetNodeAsXHTMLString (new MicroContainer ());
  _testGetNodeAsXHTMLString (new MicroComment ("useless"));
  _testGetNodeAsXHTMLString (new MicroEntityReference ("xyz"));
  try
  {
    _testGetNodeAsXHTMLString (null);
    fail ();
  }
  catch (final NullPointerException ex)
  {}
}
 
Example #12
Source File: MultilingualTextMicroTypeConverterRegistrar.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
@Nonnull
public final IMicroElement convertToMicroElement (@Nonnull final T aSource,
                                                  @Nullable final String sNamespaceURI,
                                                  @Nonnull @Nonempty final String sTagName)
{
  final IMicroElement eMText = new MicroElement (sNamespaceURI, sTagName);
  for (final Map.Entry <Locale, String> aEntry : aSource.texts ()
                                                        .getSortedByKey (Comparator.comparing (Locale::toString))
                                                        .entrySet ())
  {
    final IMicroElement eText = eMText.appendElement (sNamespaceURI, ELEMENT_TEXT);
    eText.setAttribute (ATTR_LOCALE, aEntry.getKey ().toString ());
    eText.appendText (aEntry.getValue ());
  }
  return eMText;
}
 
Example #13
Source File: MicroWriterTest.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
@Test
public void testOrderNamespaces ()
{
  XMLWriterSettings aSettings = new XMLWriterSettings ().setIndent (EXMLSerializeIndent.NONE)
                                                        .setUseDoubleQuotesForAttributes (false);

  // default order
  final IMicroElement e = new MicroElement ("urn:stringdefault", "a");
  e.setAttribute ("urn:string3", "c", "1");
  e.setAttribute ("urn:string2", "b", "2");
  e.setAttribute ("urn:string1", "a", "3");
  // Attributes are ordered automatically in DOM!
  assertEquals ("<a xmlns='urn:stringdefault' xmlns:ns0='urn:string3' ns0:c='1' xmlns:ns1='urn:string2' ns1:b='2' xmlns:ns2='urn:string1' ns2:a='3' />",
                MicroWriter.getNodeAsString (e, aSettings));

  aSettings = aSettings.setOrderAttributesAndNamespaces (true);
  assertEquals ("<a xmlns='urn:stringdefault' xmlns:ns0='urn:string3' xmlns:ns1='urn:string2' xmlns:ns2='urn:string1' ns2:a='3' ns1:b='2' ns0:c='1' />",
                MicroWriter.getNodeAsString (e, aSettings));
}
 
Example #14
Source File: StringMicroTypeConverter.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
public IMicroElement convertToMicroElement (@Nonnull final String aObject,
                                            @Nullable final String sNamespaceURI,
                                            @Nonnull @Nonempty final String sTagName)
{
  final IMicroElement e = new MicroElement (sNamespaceURI, sTagName);
  e.appendText (aObject);
  return e;
}
 
Example #15
Source File: MimeTypeInfoMicroTypeConverter.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nullable
public IMicroElement convertToMicroElement (@Nonnull final MimeTypeInfo aObject,
                                            @Nullable final String sNamespaceURI,
                                            @Nonnull final String sTagName)
{
  final IMicroElement eRet = new MicroElement (sNamespaceURI, sTagName);
  for (final MimeTypeWithSource aMimeType : aObject.getAllMimeTypesWithSource ())
  {
    eRet.appendElement (sNamespaceURI, ELEMENT_MIMETYPE)
        .setAttribute (ATTR_SOURCE, aMimeType.getSource ())
        .appendText (aMimeType.getMimeTypeAsString ());
  }
  if (aObject.hasComment ())
    eRet.appendElement (sNamespaceURI, ELEMENT_COMMENT).appendText (aObject.getComment ());
  for (final String sParentType : aObject.getAllParentTypes ())
    eRet.appendElement (sNamespaceURI, ELEMENT_PARENT_TYPE).appendText (sParentType);
  for (final String sGlob : aObject.getAllGlobs ())
    eRet.appendElement (sNamespaceURI, ELEMENT_GLOB).appendText (sGlob);
  for (final ExtensionWithSource aExtension : aObject.getAllExtensionsWithSource ())
  {
    eRet.appendElement (sNamespaceURI, ELEMENT_EXTENSION)
        .setAttribute (ATTR_SOURCE, aExtension.getSource ())
        .appendText (aExtension.getExtension ());
  }
  eRet.setAttribute (ATTR_SOURCE, aObject.getSource ());
  return eRet;
}
 
Example #16
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 #17
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 #18
Source File: PSEmph.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_EMPH);
  for (final String sContent : m_aContent)
    ret.appendText (sContent);
  return ret;
}
 
Example #19
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 #20
Source File: PSParam.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_PARAM);
  ret.setAttribute (CSchematronXML.ATTR_NAME, m_sName);
  ret.setAttribute (CSchematronXML.ATTR_VALUE, m_sValue);
  return ret;
}
 
Example #21
Source File: PSName.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_NAME);
  ret.setAttribute (CSchematronXML.ATTR_PATH, m_sPath);
  if (m_aForeignAttrs != null)
    for (final Map.Entry <String, String> aEntry : m_aForeignAttrs.entrySet ())
      ret.setAttribute (aEntry.getKey (), aEntry.getValue ());
  return ret;
}
 
Example #22
Source File: PSExtends.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_EXTENDS);
  ret.setAttribute (CSchematronXML.ATTR_RULE, m_sRule);
  if (m_aForeignAttrs != null)
    for (final Map.Entry <String, String> aEntry : m_aForeignAttrs.entrySet ())
      ret.setAttribute (aEntry.getKey (), aEntry.getValue ());
  return ret;
}
 
Example #23
Source File: PSLet.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_LET);
  ret.setAttribute (CSchematronXML.ATTR_NAME, m_sName);
  ret.setAttribute (CSchematronXML.ATTR_VALUE, m_sValue);
  return ret;
}
 
Example #24
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 #25
Source File: PSValueOf.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_VALUE_OF);
  ret.setAttribute (CSchematronXML.ATTR_SELECT, m_sSelect);
  if (m_aForeignAttrs != null)
    for (final Map.Entry <String, String> aEntry : m_aForeignAttrs.entrySet ())
      ret.setAttribute (aEntry.getKey (), aEntry.getValue ());
  return ret;
}
 
Example #26
Source File: PSInclude.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_INCLUDE);
  ret.setAttribute (CSchematronXML.ATTR_HREF, m_sHref);
  return ret;
}
 
Example #27
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 #28
Source File: PSNS.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_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;
}
 
Example #29
Source File: ColorMicroTypeConverter.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
public IMicroElement convertToMicroElement (@Nonnull final Color aObject,
                                            @Nullable final String sNamespaceURI,
                                            @Nonnull final String sTagName)
{
  final IMicroElement aElement = new MicroElement (sNamespaceURI, sTagName);

  aElement.setAttribute (ATTR_RED, aObject.getRed ());
  aElement.setAttribute (ATTR_GREEN, aObject.getGreen ());
  aElement.setAttribute (ATTR_BLUE, aObject.getBlue ());
  aElement.setAttribute (ATTR_ALPHA, aObject.getAlpha ());

  return aElement;
}
 
Example #30
Source File: TreeXMLConverter.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static <DATATYPE, ITEMTYPE extends ITreeItem <DATATYPE, ITEMTYPE>> IMicroElement getTreeAsXML (@Nonnull final IBasicTree <DATATYPE, ITEMTYPE> aTree,
                                                                                                      @Nonnull final Comparator <? super ITEMTYPE> aItemComparator,
                                                                                                      @Nonnull final IConverterTreeItemToMicroNode <? super DATATYPE> aDataConverter)
{
  final String sNamespaceURI = aDataConverter.getNamespaceURI ();
  final IMicroElement eRoot = new MicroElement (sNamespaceURI, ELEMENT_ROOT);
  fillTreeAsXML (aTree, aItemComparator, aDataConverter, eRoot);
  return eRoot;
}