当前位置: 首页>>代码示例>>Java>>正文


Java SerializationHandler.startPrefixMapping方法代码示例

本文整理汇总了Java中org.apache.xml.serializer.SerializationHandler.startPrefixMapping方法的典型用法代码示例。如果您正苦于以下问题:Java SerializationHandler.startPrefixMapping方法的具体用法?Java SerializationHandler.startPrefixMapping怎么用?Java SerializationHandler.startPrefixMapping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.xml.serializer.SerializationHandler的用法示例。


在下文中一共展示了SerializationHandler.startPrefixMapping方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ensureNamespaceDeclDeclared

import org.apache.xml.serializer.SerializationHandler; //导入方法依赖的package包/类
/**
 * This function checks to make sure a given prefix is really
 * declared.  It might not be, because it may be an excluded prefix.
 * If it's not, it still needs to be declared at this point.
 * TODO: This needs to be done at an earlier stage in the game... -sb
 *
 * NEEDSDOC @param dtm
 * NEEDSDOC @param namespace
 *
 * @throws org.xml.sax.SAXException
 */
public static void ensureNamespaceDeclDeclared(
    SerializationHandler handler,
    DTM dtm,
    int namespace)
    throws org.xml.sax.SAXException
{

    String uri = dtm.getNodeValue(namespace);
    String prefix = dtm.getNodeNameX(namespace);

    if ((uri != null && uri.length() > 0) && (null != prefix))
    {
        String foundURI;
        NamespaceMappings ns = handler.getNamespaceMappings();
        if (ns != null)
        {

            foundURI = ns.lookupNamespace(prefix);
            if ((null == foundURI) || !foundURI.equals(uri))
            {
                handler.startPrefixMapping(prefix, uri, false);
            }
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:37,代码来源:SerializerUtils.java

示例2: executeNSDecls

import org.apache.xml.serializer.SerializationHandler; //导入方法依赖的package包/类
/**
 * Send startPrefixMapping events to the result tree handler
 * for all declared prefix mappings in the stylesheet.
 *
 * @param transformer non-null reference to the the current transform-time state.
 * @param ignorePrefix string prefix to not startPrefixMapping
 *
 * @throws TransformerException
 */
void executeNSDecls(TransformerImpl transformer, String ignorePrefix) throws TransformerException
{  
  try
  {
    if (null != m_prefixTable)
    {
      SerializationHandler rhandler = transformer.getResultTreeHandler();
      int n = m_prefixTable.size();

      for (int i = n - 1; i >= 0; i--)
      {
        XMLNSDecl decl = (XMLNSDecl) m_prefixTable.get(i);

        if (!decl.getIsExcluded() && !(null != ignorePrefix && decl.getPrefix().equals(ignorePrefix)))
        {
          rhandler.startPrefixMapping(decl.getPrefix(), decl.getURI(), true);
        }
      }
    }
  }
  catch(org.xml.sax.SAXException se)
  {
    throw new TransformerException(se);
  }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:35,代码来源:ElemTemplateElement.java

示例3: outputResultTreeFragment

import org.apache.xml.serializer.SerializationHandler; //导入方法依赖的package包/类
/**
 * Given a result tree fragment, walk the tree and
 * output it to the SerializationHandler.
 *
 * @param obj Result tree fragment object
 * @param support XPath context for the result tree fragment
 *
 * @throws org.xml.sax.SAXException
 */
public static void outputResultTreeFragment(
    SerializationHandler handler,
    XObject obj,
    XPathContext support)
    throws org.xml.sax.SAXException
{

    int doc = obj.rtf();
    DTM dtm = support.getDTM(doc);

    if (null != dtm)
    {
        for (int n = dtm.getFirstChild(doc);
            DTM.NULL != n;
            n = dtm.getNextSibling(n))
        {
            handler.flushPending();

            // I think. . . . This used to have a (true) arg
            // to flush prefixes, will that cause problems ???
            if (dtm.getNodeType(n) == DTM.ELEMENT_NODE
                    && dtm.getNamespaceURI(n) == null)
                handler.startPrefixMapping("", "");
            dtm.dispatchToEvents(n, handler);
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:37,代码来源:SerializerUtils.java

示例4: constructNode

import org.apache.xml.serializer.SerializationHandler; //导入方法依赖的package包/类
/**
 * Construct a node in the result tree.  This method is overloaded by 
 * xsl:attribute. At this class level, this method creates an element.
 * If the node is null, we instantiate only the content of the node in accordance
 * with section 7.1.2 of the XSLT 1.0 Recommendation.
 *
 * @param nodeName The name of the node, which may be <code>null</code>.  If <code>null</code>,
 *                 only the non-attribute children of this node will be processed.
 * @param prefix The prefix for the namespace, which may be <code>null</code>.
 *               If not <code>null</code>, this prefix will be mapped and unmapped.
 * @param nodeNamespace The namespace of the node, which may be not be <code>null</code>.
 * @param transformer non-null reference to the the current transform-time state.
 *
 * @throws TransformerException
 */
void constructNode(
        String nodeName, String prefix, String nodeNamespace, TransformerImpl transformer)
          throws TransformerException
{

  boolean shouldAddAttrs;

  try
  {
    SerializationHandler rhandler = transformer.getResultTreeHandler();

    if (null == nodeName)
    {
      shouldAddAttrs = false;
    }
    else
    {
      if (null != prefix)
      {
        rhandler.startPrefixMapping(prefix, nodeNamespace, true);
      }

      rhandler.startElement(nodeNamespace, QName.getLocalPart(nodeName),
                            nodeName);

      super.execute(transformer);

      shouldAddAttrs = true;
    }

    transformer.executeChildTemplates(this, shouldAddAttrs);

    // Now end the element if name was valid
    if (null != nodeName)
    {
      rhandler.endElement(nodeNamespace, QName.getLocalPart(nodeName),
                          nodeName);
      if (null != prefix)
      {
        rhandler.endPrefixMapping(prefix);
      }
    }
  }
  catch (SAXException se)
  {
    throw new TransformerException(se);
  }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:64,代码来源:ElemElement.java


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