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


Java XmlCursor.toStartDoc方法代码示例

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


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

示例1: createTextElement

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @param qname
 * @param value
 * @return
 */
static XML createTextElement(XMLLibImpl lib, javax.xml.namespace.QName qname, String value)
{
    XScriptAnnotation anno;

    XmlObject xo = XmlObject.Factory.newInstance();
    XmlCursor cursor = xo.newCursor();
    try {
        cursor.toNextToken();

        cursor.beginElement(qname.getLocalPart(), qname.getNamespaceURI());
        //if(namespace.length() > 0)
        //    cursor.insertNamespace("", namespace);
        cursor.insertChars(value);

        cursor.toStartDoc();
        cursor.toNextToken();
        anno = new XScriptAnnotation(cursor);
        cursor.setBookmark(anno);
    } finally {
        cursor.dispose();
    }

    return new XML(lib, anno);
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:31,代码来源:XML.java

示例2: tableClicked

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
private void tableClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableClicked
    if (evt.getClickCount() > 1 && selectedSequence != null
        && sequenceTable.getRowCount() > 0) {
        int row = sequenceTable.rowAtPoint(evt.getPoint());
        if (row >= 0 && row < selectedSequence.size()) {
            EventFile up = selectedSequence.get(row);
            if (up.getEventParameters() != null) {
                JDialog dialog = new JDialog(this, true);
                //dialog.setLocationByPlatform(true);
                JTextArea textArea = new JTextArea(100, 100);
                textArea.setEditable(false);
                textArea.setAutoscrolls(true);
                //textArea.setPreferredSize(new Dimension(900, 500));
                //textArea.setBorder(BorderFactory.createLineBorder(Color.BLACK));
                //textArea.setFont(new Font("courier new", Font.PLAIN, 12));
                textArea.setLineWrap(true);
                JScrollPane scroll = new JScrollPane();
                scroll.setViewportView(textArea);
                scroll.setAutoscrolls(true);

                XmlCursor cursor = up.getEventParameters().newCursor();
                cursor.toStartDoc();
                textArea.setText(cursor.getObject().xmlText());
                cursor.dispose();

                dialog.add(scroll);
                dialog.pack();
                dialog.setVisible(true);
            }
            evt.consume();
        }
    }
}
 
开发者ID:SED-EEW,项目名称:EEWD,代码行数:34,代码来源:EventBrowser.java

示例3: copy

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @param cursToCopy
 * @return
 */
private XmlCursor copy (XmlCursor cursToCopy)
{
    XmlObject xo = XmlObject.Factory.newInstance();

    XmlCursor copyCurs = null;

    if (cursToCopy.currentTokenType().isText())
    {
        try
        {
            // Try just as a textnode, to do that we need to wrap the text in a special fragment tag
            // that is not visible from the XmlCursor.
            copyCurs = XmlObject.Factory.parse("<x:fragment xmlns:x=\"http://www.openuri.org/fragment\">" +
                                       cursToCopy.getChars() +
                                       "</x:fragment>").newCursor();
            if (!cursToCopy.toNextSibling())
            {
                if (cursToCopy.currentTokenType().isText())
                {
                    cursToCopy.toNextToken();   // It's not an element it's text so skip it.
                }
            }
        }
        catch (Exception ex)
        {
            throw ScriptRuntime.typeError(ex.getMessage());
        }
    }
    else
    {
        copyCurs = xo.newCursor();
        copyCurs.toFirstContentToken();
        if (cursToCopy.currentTokenType() == XmlCursor.TokenType.STARTDOC)
        {
            cursToCopy.toNextToken();
        }
        
        cursToCopy.copyXml(copyCurs);
        if (!cursToCopy.toNextSibling())        // If element skip element.
        {
            if (cursToCopy.currentTokenType().isText())
            {
                cursToCopy.toNextToken();       // It's not an element it's text so skip it.
            }
        }

    }

    copyCurs.toStartDoc();
    copyCurs.toFirstContentToken();

    return copyCurs;
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:59,代码来源:XML.java

示例4: copy

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @param cursToCopy
 * @return
 */
private XmlCursor copy (XmlCursor cursToCopy)
{
    XmlObject xo = XmlObject.Factory.newInstance();

    XmlCursor copyCurs = null;

    if (cursToCopy.currentTokenType().isText())
    {
        try
        {
            // Try just as a textnode, to do that we need to wrap the text in a special fragment tag
            // that is not visible from the XmlCursor.
            copyCurs = XmlObject.Factory.parse("<x:fragment xmlns:x=\"http://www.openuri.org/fragment\">" +
                                       cursToCopy.getChars() +
                                       "</x:fragment>").newCursor();
            if (!cursToCopy.toNextSibling())
            {
                if (cursToCopy.currentTokenType().isText())
                {
                    cursToCopy.toNextToken();   // It's not an element it's text so skip it.
                }
            }
        }
        catch (Exception ex)
        {
            throw ScriptRuntime.typeError(ex.getMessage());
        }
    }
    else
    {
        copyCurs = xo.newCursor();
        copyCurs.toFirstContentToken();
        if (cursToCopy.currentTokenType() == XmlCursor.TokenType.STARTDOC)
        {
            cursToCopy.toNextToken();
        }

        cursToCopy.copyXml(copyCurs);
        if (!cursToCopy.toNextSibling())        // If element skip element.
        {
            if (cursToCopy.currentTokenType().isText())
            {
                cursToCopy.toNextToken();       // It's not an element it's text so skip it.
            }
        }

    }

    copyCurs.toStartDoc();
    copyCurs.toFirstContentToken();

    return copyCurs;
}
 
开发者ID:CyboticCatfish,项目名称:code404,代码行数:59,代码来源:XML.java


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