• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java OutputPropertiesFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory的典型用法代码示例。如果您正苦于以下问题:Java OutputPropertiesFactory类的具体用法?Java OutputPropertiesFactory怎么用?Java OutputPropertiesFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OutputPropertiesFactory类属于com.sun.org.apache.xml.internal.serializer包,在下文中一共展示了OutputPropertiesFactory类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setDefaults

import com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory; //导入依赖的package包/类
/**
 * Internal method to get the default properties from the
 * serializer factory and set them on the property object.
 * @param props a java.util.Property object on which the properties are set.
 * @param method The output method type, one of "xml", "text", "html" ...
 */
private void setDefaults(Properties props, String method)
{
        final Properties method_props =
                OutputPropertiesFactory.getDefaultMethodProperties(method);
        {
                final Enumeration names = method_props.propertyNames();
                while (names.hasMoreElements())
                {
                        final String name = (String)names.nextElement();
                        props.setProperty(name, method_props.getProperty(name));
                }
        }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:TransformerImpl.java


示例2: validOutputProperty

import com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory; //导入依赖的package包/类
/**
 * Verifies if a given output property name is a property defined in
 * the JAXP 1.1 / TrAX spec
 */
private boolean validOutputProperty(String name) {
    return (name.equals(OutputKeys.ENCODING) ||
            name.equals(OutputKeys.METHOD) ||
            name.equals(OutputKeys.INDENT) ||
            name.equals(OutputKeys.DOCTYPE_PUBLIC) ||
            name.equals(OutputKeys.DOCTYPE_SYSTEM) ||
            name.equals(OutputKeys.CDATA_SECTION_ELEMENTS) ||
            name.equals(OutputKeys.MEDIA_TYPE) ||
            name.equals(OutputKeys.OMIT_XML_DECLARATION)   ||
            name.equals(OutputKeys.STANDALONE) ||
            name.equals(OutputKeys.VERSION) ||
            name.equals(OutputPropertiesFactory.ORACLE_IS_STANDALONE) ||
            name.charAt(0) == '{');
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:TransformerImpl.java


示例3: LSSerializerImpl

import com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory; //导入依赖的package包/类
/**
 * Constructor:  Creates a LSSerializerImpl object.  The underlying
 * XML 1.0 or XML 1.1 org.apache.xml.serializer.Serializer object is
 * created and initialized the first time any of the write methods are
 * invoked to serialize the Node.  Subsequent write methods on the same
 * LSSerializerImpl object will use the previously created Serializer object.
 */
public LSSerializerImpl () {
    // set default parameters
    fFeatures |= CDATA;
    fFeatures |= COMMENTS;
    fFeatures |= ELEM_CONTENT_WHITESPACE;
    fFeatures |= ENTITIES;
    fFeatures |= NAMESPACES;
    fFeatures |= NAMESPACEDECLS;
    fFeatures |= SPLITCDATA;
    fFeatures |= WELLFORMED;
    fFeatures |= DISCARDDEFAULT;
    fFeatures |= XMLDECL;

    // New OutputFormat properties
    fDOMConfigProperties = new Properties();

    // Initialize properties to be passed on the underlying serializer
    initializeSerializerProps();

    // Read output_xml.properties and System Properties to initialize properties
    Properties  configProps = OutputPropertiesFactory.getDefaultMethodProperties("xml");

    // change xml version from 1.0 to 1.1
    //configProps.setProperty("version", "1.1");

    // Get a serializer that seriailizes according to the properties,
    // which in this case is to xml
    fXMLSerializer = new ToXMLStream();
    fXMLSerializer.setOutputFormat(configProps);

    // Initialize Serializer
    fXMLSerializer.setOutputFormat(fDOMConfigProperties);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:LSSerializerImpl.java


示例4: formatXmlString

import com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory; //导入依赖的package包/类
public String formatXmlString(String xml) {
    StringWriter writer = new StringWriter();
    try {

        Transformer transformer = TransformerFactory.newInstance().newTransformer();
        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
        transformer.setOutputProperty(OutputPropertiesFactory.S_KEY_INDENT_AMOUNT, "1");
        transformer.transform(new StreamSource(new StringReader(xml)), new StreamResult(writer));

    } catch (Exception e) {
        logger.error("Formatting XmlString went wrong", e);
    }
    StringBuffer buffer = writer.getBuffer();
    return buffer.toString();
}
 
开发者ID:opennms-forge,项目名称:opennms-rest-client-api,代码行数:16,代码来源:XmlHelper.java


示例5: transferOutputProperties

import com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory; //导入依赖的package包/类
/**
 * Internal method to pass any properties to the translet prior to
 * initiating the transformation
 */
private void transferOutputProperties(AbstractTranslet translet)
{
    // Return right now if no properties are set
    if (_properties == null) return;

    // Get a list of all the defined properties
    Enumeration names = _properties.propertyNames();
    while (names.hasMoreElements()) {
        // Note the use of get() instead of getProperty()
        String name  = (String) names.nextElement();
        String value = (String) _properties.get(name);

        // Ignore default properties
        if (value == null) continue;

        // Pass property value to translet - override previous setting
        if (name.equals(OutputKeys.ENCODING)) {
            translet._encoding = value;
        }
        else if (name.equals(OutputKeys.METHOD)) {
            translet._method = value;
        }
        else if (name.equals(OutputKeys.DOCTYPE_PUBLIC)) {
            translet._doctypePublic = value;
        }
        else if (name.equals(OutputKeys.DOCTYPE_SYSTEM)) {
            translet._doctypeSystem = value;
        }
        else if (name.equals(OutputKeys.MEDIA_TYPE)) {
            translet._mediaType = value;
        }
        else if (name.equals(OutputKeys.STANDALONE)) {
            translet._standalone = value;
        }
        else if (name.equals(OutputKeys.VERSION)) {
            translet._version = value;
        }
        else if (name.equals(OutputKeys.OMIT_XML_DECLARATION)) {
            translet._omitHeader =
                (value != null && value.toLowerCase().equals("yes"));
        }
        else if (name.equals(OutputKeys.INDENT)) {
            translet._indent =
                (value != null && value.toLowerCase().equals("yes"));
        }
        else if (name.equals(OutputPropertiesFactory.S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL +"indent-amount")) {
             if (value != null) {
                 translet._indentamount = Integer.parseInt(value);
             }
        }
        else if (name.equals(OutputPropertiesFactory.S_BUILTIN_EXTENSIONS_UNIVERSAL +"indent-amount")) {
             if (value != null) {
                 translet._indentamount = Integer.parseInt(value);
             }
        }
        else if (name.equals(OutputKeys.CDATA_SECTION_ELEMENTS)) {
            if (value != null) {
                translet._cdata = null; // clear previous setting
                StringTokenizer e = new StringTokenizer(value);
                while (e.hasMoreTokens()) {
                    translet.addCdataElement(e.nextToken());
                }
            }
        }
        else if (name.equals(OutputPropertiesFactory.ORACLE_IS_STANDALONE)) {
             if (value != null && value.equals("yes")) {
                 translet._isStandalone = true;
             }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:76,代码来源:TransformerImpl.java


示例6: loadSerializer

import com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory; //导入依赖的package包/类
/**
 * Create an instance of Xalan serializer for the sake of serializing an XML
 * value according the SQL/XML specification for serialization.
 */
private void loadSerializer() throws java.io.IOException {
  // Set serialization properties.

  // using JDK5's class
  Properties props = OutputPropertiesFactory
      .getDefaultMethodProperties("xml");
  /* (original code)
  Properties props = OutputProperties.getDefaultMethodProperties("xml");
  */

  // SQL/XML[2006] 10.15:General Rules:6 says method is "xml".
  props.setProperty(OutputKeys.METHOD, "xml");

  /* Since the XMLSERIALIZE operator doesn't currently support
   * the DOCUMENT nor CONTENT keywords, SQL/XML spec says that
   * the default is CONTENT (6.7:Syntax Rules:2.a).  Further,
   * since the XMLSERIALIZE operator doesn't currently support the
   * <XML declaration option> syntax, the SQL/XML spec says
   * that the default for that option is "Unknown" (6.7:General
   * Rules:2.f).  Put those together and that in turn means that
   * the value of "OMIT XML DECLARATION" must be "Yes", as
   * stated in section 10.15:General Rules:8.c.  SO, that's what
   * we set here.
   *
   * NOTE: currently the only way to view the contents of an
   * XML column is by using an explicit XMLSERIALIZE operator.
   * This means that if an XML document is stored and it
   * begins with an XML declaration, the user will never be
   * able to _see_ that declaration after inserting the doc
   * because, as explained above, our current support for
   * XMLSERIALIZE dictates that the declaration must be
   * omitted.  Similarly, other transformations that may
   * occur from serialization (ex. entity replacement,
   * attribute order, single-to-double quotes, etc)) will
   * always be in effect for the string returned to the user;
   * the original form of the XML document, if different
   * from the serialized version, is not currently retrievable.
   */
  props.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");

  // We serialize everything as UTF-8 to match what we
  // store on disk.
  props.setProperty(OutputKeys.ENCODING, "UTF-8");

  // Load the serializer with the correct properties.
  serializer = SerializerFactory.getSerializer(props);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:52,代码来源:SqlXmlHelperSun5.java



注:本文中的com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java InjectPresenter类代码示例发布时间:2022-05-22
下一篇:
Java Awareness类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap