本文整理汇总了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);
}
示例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();
}
}
}
示例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;
}
示例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;
}