Search in sources :

Example 1 with MicroElement

use of com.helger.xml.microdom.MicroElement in project ph-schematron by phax.

the class PSSpan method getAsMicroElement.

@Nonnull
public IMicroElement getAsMicroElement() {
    final IMicroElement ret = new MicroElement(CSchematron.NAMESPACE_SCHEMATRON, CSchematronXML.ELEMENT_SPAN);
    ret.setAttribute(CSchematronXML.ATTR_CLASS, m_sClass);
    if (m_aForeignElements != null)
        for (final IMicroElement aForeignElement : m_aForeignElements) ret.appendChild(aForeignElement.getClone());
    for (final String sContent : m_aContent) ret.appendText(sContent);
    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 2 with MicroElement

use of com.helger.xml.microdom.MicroElement in project ph-schematron by phax.

the class PSValueOf method getAsMicroElement.

@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;
}
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 3 with MicroElement

use of com.helger.xml.microdom.MicroElement in project ph-css by phax.

the class MainCreateSupportedCSSPropertiesFile method main.

public static void main(final String[] args) {
    final Locale aLocale = Locale.US;
    final IMicroElement html = new MicroElement("html");
    final IMicroElement head = html.appendElement("head");
    head.appendElement("title").appendText("Supported CSS properties in ph-css");
    head.appendElement("style").appendText("* {font-family:Arial,Helvetica;}" + " table{border-collapse:collapse;}" + " td,th {border:solid 1px black;padding:3px;vertical-align:top; }" + " .odd{background-color:#ddd;}" + " .center{text-align:center;}" + " .nowrap{white-space:nowrap;}" + " a, a:link, a:visited, a:hover, a:active{color:blue;}");
    final IMicroElement body = html.appendElement("body");
    body.appendElement("div").appendText("Automatically generated by " + ClassHelper.getClassLocalName(MainCreateSupportedCSSPropertiesFile.class) + " on " + new Date().toString());
    body.appendElement("div").appendElement("a").setAttribute("href", "#generic").appendText("Generic properties");
    body.appendElement("div").appendElement("a").setAttribute("href", "#vendor").appendText("Vendor specific properties");
    body.appendElement("a").setAttribute("name", "generic").appendText("");
    body.appendElement("h1").appendText("Generic properties");
    IMicroElement table = body.appendElement("table");
    IMicroElement thead = table.appendElement("thead");
    IMicroElement tr = thead.appendElement("tr");
    tr.appendElement("th").appendText("Name");
    tr.appendElement("th").appendText("CSS 1.0");
    tr.appendElement("th").appendText("CSS 2.1");
    tr.appendElement("th").appendText("CSS 3.0");
    tr.appendElement("th").appendText("Links");
    IMicroElement tbody = table.appendElement("tbody");
    int nIndex = 0;
    for (final ECSSProperty eProperty : CollectionHelper.getSorted(ECSSProperty.values(), IHasName.getComparatorName())) if (!eProperty.isVendorSpecific()) {
        final Version eMinVersion = eProperty.getMinimumCSSVersion().getVersion();
        final boolean bCSS10 = eMinVersion.isLE(ECSSVersion.CSS10.getVersion());
        final boolean bCSS21 = eMinVersion.isLE(ECSSVersion.CSS21.getVersion());
        final boolean bCSS30 = eMinVersion.isLE(ECSSVersion.CSS30.getVersion());
        tr = tbody.appendElement("tr");
        if ((nIndex & 1) == 1)
            tr.setAttribute("class", "odd");
        tr.appendElement("td").setAttribute("class", "nowrap").appendText(eProperty.getName());
        _boolean(tr.appendElement("td"), bCSS10, null);
        _boolean(tr.appendElement("td"), bCSS21, null);
        _boolean(tr.appendElement("td"), bCSS30, null);
        final IMicroElement td = tr.appendElement("td");
        for (final ECSSSpecification eSpecs : eProperty.getAllSpecifications()) if (eSpecs.hasHandledURL())
            td.appendElement("div").appendElement("a").setAttribute("href", eSpecs.getHandledURL()).setAttribute("target", "_blank").appendText(eSpecs.getID());
        else
            td.appendElement("div").appendText(eSpecs.getID());
        ++nIndex;
    }
    // Determine all used vendor prefixes
    final EnumSet<ECSSVendorPrefix> aRequiredPrefixes = EnumSet.noneOf(ECSSVendorPrefix.class);
    for (final ECSSVendorPrefix eVendorPrefix : ECSSVendorPrefix.values()) {
        for (final ECSSProperty eProperty : ECSSProperty.values()) if (eProperty.isVendorSpecific(eVendorPrefix)) {
            aRequiredPrefixes.add(eVendorPrefix);
            break;
        }
    }
    body.appendElement("a").setAttribute("name", "vendor").appendText("");
    body.appendElement("h1").appendText("Vendor specific properties");
    table = body.appendElement("table");
    thead = table.appendElement("thead");
    tr = thead.appendElement("tr");
    tr.appendElement("th").appendText("Name");
    for (final ECSSVendorPrefix e : aRequiredPrefixes) {
        final IMicroElement th = tr.appendElement("th");
        th.appendText(e.getDisplayName());
        th.appendElement("span").setAttribute("class", "nowrap").appendText(" (" + e.getPrefix() + ")");
    }
    tbody = table.appendElement("tbody");
    nIndex = 0;
    for (final ECSSProperty eProperty : CollectionHelper.getSorted(ECSSProperty.values(), IComparator.getComparatorCollating(ECSSProperty::getVendorIndependentName, aLocale))) if (eProperty.isVendorSpecific()) {
        tr = tbody.appendElement("tr");
        if ((nIndex & 1) == 1)
            tr.setAttribute("class", "odd");
        tr.appendElement("td").setAttribute("class", "nowrap").appendText(eProperty.getVendorIndependentName());
        for (final ECSSVendorPrefix e : aRequiredPrefixes) _boolean(tr.appendElement("td"), eProperty.isVendorSpecific(e), eProperty.getName());
        ++nIndex;
    }
    body.appendElement("div").setAttribute("style", "margin:2em 0").appendText("That's it.");
    String sHTML = "<!--\r\n" + "\r\n" + "    Copyright (C) 2014 Philip Helger (www.helger.com)\r\n" + "    philip[at]helger[dot]com\r\n" + "\r\n" + "    Licensed under the Apache License, Version 2.0 (the \"License\");\r\n" + "    you may not use this file except in compliance with the License.\r\n" + "    You may obtain a copy of the License at\r\n" + "\r\n" + "            http://www.apache.org/licenses/LICENSE-2.0\r\n" + "\r\n" + "    Unless required by applicable law or agreed to in writing, software\r\n" + "    distributed under the License is distributed on an \"AS IS\" BASIS,\r\n" + "    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n" + "    See the License for the specific language governing permissions and\r\n" + "    limitations under the License.\r\n" + "\r\n" + "-->\r\n";
    sHTML += MicroWriter.getNodeAsString(html, new XMLWriterSettings().setIndent(EXMLSerializeIndent.ALIGN_ONLY).setSerializeVersion(EXMLSerializeVersion.HTML));
    SimpleFileIO.writeFile(new File("src/main/resources/supported-css-properties.html"), sHTML, StandardCharsets.UTF_8);
    System.out.println("Done");
}
Also used : Locale(java.util.Locale) MicroElement(com.helger.xml.microdom.MicroElement) IMicroElement(com.helger.xml.microdom.IMicroElement) XMLWriterSettings(com.helger.xml.serialize.write.XMLWriterSettings) ECSSVendorPrefix(com.helger.css.ECSSVendorPrefix) Date(java.util.Date) ECSSSpecification(com.helger.css.ECSSSpecification) ECSSVersion(com.helger.css.ECSSVersion) EXMLSerializeVersion(com.helger.xml.serialize.write.EXMLSerializeVersion) Version(com.helger.commons.version.Version) IMicroElement(com.helger.xml.microdom.IMicroElement) ECSSProperty(com.helger.css.property.ECSSProperty) File(java.io.File)

Example 4 with MicroElement

use of com.helger.xml.microdom.MicroElement in project ph-schematron by phax.

the class PSInclude method getAsMicroElement.

@Nonnull
public IMicroElement getAsMicroElement() {
    final IMicroElement ret = new MicroElement(CSchematron.NAMESPACE_SCHEMATRON, CSchematronXML.ELEMENT_INCLUDE);
    ret.setAttribute(CSchematronXML.ATTR_HREF, m_sHref);
    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)

Example 5 with MicroElement

use of com.helger.xml.microdom.MicroElement in project ph-schematron by phax.

the class PSName method getAsMicroElement.

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

Aggregations

IMicroElement (com.helger.xml.microdom.IMicroElement)18 MicroElement (com.helger.xml.microdom.MicroElement)18 Nonnull (javax.annotation.Nonnull)17 Version (com.helger.commons.version.Version)1 ECSSSpecification (com.helger.css.ECSSSpecification)1 ECSSVendorPrefix (com.helger.css.ECSSVendorPrefix)1 ECSSVersion (com.helger.css.ECSSVersion)1 ECSSProperty (com.helger.css.property.ECSSProperty)1 EXMLSerializeVersion (com.helger.xml.serialize.write.EXMLSerializeVersion)1 XMLWriterSettings (com.helger.xml.serialize.write.XMLWriterSettings)1 File (java.io.File)1 Date (java.util.Date)1 Locale (java.util.Locale)1