當前位置: 首頁>>代碼示例>>Java>>正文


Java XmlObject類代碼示例

本文整理匯總了Java中org.apache.xmlbeans.XmlObject的典型用法代碼示例。如果您正苦於以下問題:Java XmlObject類的具體用法?Java XmlObject怎麽用?Java XmlObject使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


XmlObject類屬於org.apache.xmlbeans包,在下文中一共展示了XmlObject類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createSample

import org.apache.xmlbeans.XmlObject; //導入依賴的package包/類
public String createSample( SchemaType sType )
{
	XmlObject object = XmlObject.Factory.newInstance();
	XmlCursor cursor = object.newCursor();
	// Skip the document node
	cursor.toNextToken();
	// Using the type and the cursor, call the utility method to get a
	// sample XML payload for that Schema element
	createSampleForType( sType, cursor );
	// Cursor now contains the sample payload
	// Pretty print the result. Note that the cursor is positioned at the
	// end of the doc so we use the original xml object that the cursor was
	// created upon to do the xmlText() against.

	cursor.dispose();

	XmlOptions options = new XmlOptions();
	options.put( XmlOptions.SAVE_PRETTY_PRINT );
	options.put( XmlOptions.SAVE_PRETTY_PRINT_INDENT, 3 );
	options.put( XmlOptions.SAVE_AGGRESSIVE_NAMESPACES );
	options.setSaveOuter();
	String result = object.xmlText( options );

	return result;
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:26,代碼來源:SampleXmlUtil.java

示例2: createSampleForElement

import org.apache.xmlbeans.XmlObject; //導入依賴的package包/類
public static String createSampleForElement( SchemaGlobalElement element )
{
	XmlObject xml = XmlObject.Factory.newInstance();

	XmlCursor c = xml.newCursor();
	c.toNextToken();
	c.beginElement( element.getName() );

	new SampleXmlUtil( false ).createSampleForType( element.getType(), c );

	c.dispose();

	XmlOptions options = new XmlOptions();
	options.put( XmlOptions.SAVE_PRETTY_PRINT );
	options.put( XmlOptions.SAVE_PRETTY_PRINT_INDENT, 3 );
	options.put( XmlOptions.SAVE_AGGRESSIVE_NAMESPACES );
	options.setSaveOuter();
	String result = xml.xmlText( options );

	return result;
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:22,代碼來源:SampleXmlUtil.java

示例3: initAssertions

import org.apache.xmlbeans.XmlObject; //導入依賴的package包/類
private void initAssertions(TestStepConfig testStepData) {
        if(testStepData != null && testStepData.getConfig() != null){
            XmlObject config = testStepData.getConfig();
            XmlObject[] assertionsSections = config.selectPath("$this/" + ASSERTION_SECTION);
            for(XmlObject assertionSection: assertionsSections){
//                //TestAssertionConfig assertionConfig = TestAssertionConfig.Factory.newInstance();
//                //assertionConfig.set(assertionSection);
//                TestAssertionConfig assertionConfig = (TestAssertionConfig)( assertionSection.changeType(TestAssertionConfig.type));
                TestAssertionConfig assertionConfig;
                try {
                    assertionConfig = TestAssertionConfig.Factory.parse(assertionSection.toString());
                }
                catch(XmlException e){
                    SoapUI.logError(e);
                    continue;
                }
                assertionConfigs.add(assertionConfig);
            }
        }
        assertionsSupport = new AssertionsSupport(this, new AssertableConfigImpl());
    }
 
開發者ID:SmartBear,項目名稱:ready-mqtt-plugin,代碼行數:22,代碼來源:ReceiveTestStep.java

示例4: escapeAttributeValue

import org.apache.xmlbeans.XmlObject; //導入依賴的package包/類
/**
 * Escapes the reserved characters in a value of an attribute
 *
 * @param value Unescaped text
 * @return The escaped text
 */
public String escapeAttributeValue(Object value)
{
    String text = ScriptRuntime.toString(value);

    if (text.length() == 0) return "";

    XmlObject xo = XmlObject.Factory.newInstance();

    XmlCursor cursor = xo.newCursor();
    cursor.toNextToken();
    cursor.beginElement("a");
    cursor.insertAttributeWithValue("a", text);
    cursor.dispose();

    String elementText = xo.toString();
    int begin = elementText.indexOf('"');
    int end = elementText.lastIndexOf('"');
    return elementText.substring(begin + 1, end);
}
 
開發者ID:CyboticCatfish,項目名稱:code404,代碼行數:26,代碼來源:XMLLibImpl.java

示例5: render

import org.apache.xmlbeans.XmlObject; //導入依賴的package包/類
@Override
public void render(ElementTemplate eleTemplate, Object data,
		XWPFTemplate template) {
	NiceXWPFDocument doc = template.getXWPFDocument();
	RunTemplate runTemplate = (RunTemplate) eleTemplate;
	XWPFRun run = runTemplate.getRun();
	try {
		XmlCursor newCursor = ((XWPFParagraph)run.getParent()).getCTP().newCursor();
		newCursor.toParent();
		//if (newCursor.getObject() instanceof CTTc) 
		newCursor.toParent();
		newCursor.toParent();
		XmlObject object = newCursor.getObject();
		XWPFTable table = doc.getTable((CTTbl) object);
		render(table, data);
	} catch (Exception e) {
		logger.error("dynamic table error:" + e.getMessage(), e);
	}
}
 
開發者ID:Sayi,項目名稱:poi-tl,代碼行數:20,代碼來源:DynamicTableRenderPolicy.java

示例6: createSampleForType

import org.apache.xmlbeans.XmlObject; //導入依賴的package包/類
public static String createSampleForType( SchemaType sType )
{
	XmlObject object = XmlObject.Factory.newInstance();
	XmlCursor cursor = object.newCursor();
	// Skip the document node
	cursor.toNextToken();
	// Using the type and the cursor, call the utility method to get a
	// sample XML payload for that Schema element
	new SampleXmlUtil( false ).createSampleForType( sType, cursor );
	// Cursor now contains the sample payload
	// Pretty print the result. Note that the cursor is positioned at the
	// end of the doc so we use the original xml object that the cursor was
	// created upon to do the xmlText() against.

	cursor.dispose();
	XmlOptions options = new XmlOptions();
	options.put( XmlOptions.SAVE_PRETTY_PRINT );
	options.put( XmlOptions.SAVE_PRETTY_PRINT_INDENT, 3 );
	options.put( XmlOptions.SAVE_AGGRESSIVE_NAMESPACES );
	options.setSaveOuter();
	String result = object.xmlText( options );

	return result;
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:25,代碼來源:SampleXmlUtil.java

示例7: createTextElement

import org.apache.xmlbeans.XmlObject; //導入依賴的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

示例8: createFromXmlObject

import org.apache.xmlbeans.XmlObject; //導入依賴的package包/類
static XML createFromXmlObject(XMLLibImpl lib, XmlObject xo)
{
    XScriptAnnotation anno;
    XmlCursor curs = xo.newCursor();
    if (curs.currentTokenType().isStartdoc())
    {
        curs.toFirstContentToken();
    }
    try {
        anno = new XScriptAnnotation(curs);
        curs.setBookmark(anno);
    } finally {
        curs.dispose();
    }
    return new XML(lib, anno);
}
 
開發者ID:middle2tw,項目名稱:whackpad,代碼行數:17,代碼來源:XML.java

示例9: escapeTextValue

import org.apache.xmlbeans.XmlObject; //導入依賴的package包/類
/**
 * Escapes the reserved characters in a value of a text node
 *
 * @param value Unescaped text
 * @return The escaped text
 */
public String escapeTextValue(Object value)
{
    if (value instanceof XMLObjectImpl) {
        return ((XMLObjectImpl)value).toXMLString(0);
    }

    String text = ScriptRuntime.toString(value);

    if (text.length() == 0) return text;

    XmlObject xo = XmlObject.Factory.newInstance();

    XmlCursor cursor = xo.newCursor();
    cursor.toNextToken();
    cursor.beginElement("a");
    cursor.insertChars(text);
    cursor.dispose();

    String elementText = xo.toString();
    int begin = elementText.indexOf('>') + 1;
    int end = elementText.lastIndexOf('<');
    return (begin < end) ? elementText.substring(begin, end) : "";
}
 
開發者ID:middle2tw,項目名稱:whackpad,代碼行數:30,代碼來源:XMLLibImpl.java

示例10: handleEventMessage

import org.apache.xmlbeans.XmlObject; //導入依賴的package包/類
public String handleEventMessage(String message, Object msgdoc, Map<String,String> metaInfo)
        throws EventHandlerException {
    ActionRequestDocument xmlbean = (ActionRequestDocument)
            ((XmlObject)msgdoc).changeType(ActionRequestDocument.type);
    String subaction = getSubAction(xmlbean);
    try {
        if (subaction.equals("LaunchProcess")) return handleProcessLaunch(xmlbean, message, metaInfo);
        else if (subaction.equals("Timeout")) return handleTimeout(xmlbean, message, metaInfo);
        else if (subaction.equals("Signal")) return handleNotifyProcess(xmlbean, message, metaInfo);
        else if (subaction.equals("NotifyProcess")) return handleNotifyProcess(xmlbean, message, metaInfo);
        else if (subaction.equals("Watching")) return handleWatching(xmlbean, message, metaInfo);
        else if (subaction.equals("Stubbing")) return handleStubbing(xmlbean, message, metaInfo);
        else if (subaction.equals("TaskAction")) return handleTaskAction(xmlbean, message, metaInfo);
        else throw new Exception("Unknown subaction " + subaction);
    } catch (Exception e) {
        logger.severeException(e.getMessage(), e);
        return createErrorResponse(e.getClass().getName() + ": " + e.getMessage());
    }
}
 
開發者ID:CenturyLinkCloud,項目名稱:mdw,代碼行數:20,代碼來源:RegressionTestEventHandler.java

示例11: getXml

import org.apache.xmlbeans.XmlObject; //導入依賴的package包/類
public String getXml(XmlObject request, Map<String,String> metaInfo) throws ServiceException {
    String className = metaInfo.get(JOB_CLASS_NAME);
    if (className == null)
        throw new ServiceException("Missing parameter to RunScheduledJob: " + JOB_CLASS_NAME);

    CallURL url = new CallURL(className);
    try {
        ScheduledJob job = MdwServiceRegistry.getInstance().getScheduledJob(className);
        if (job == null) {
            Class<? extends ScheduledJob> jobClass = Class.forName(className).asSubclass(ScheduledJob.class);
            job = jobClass.newInstance();
        }
        job.run(url);

        StatusMessage statusMessage = new StatusMessage();
        statusMessage.setCode(0);
        statusMessage.setMessage("Triggered ScheduledJob: " + url);
        return statusMessage.getXml();
    }
    catch (Exception ex) {
        logger.severeException(ex.getMessage(), ex);
        throw new ServiceException(ex.getMessage(), ex);
    }
}
 
開發者ID:CenturyLinkCloud,項目名稱:mdw,代碼行數:25,代碼來源:RunScheduledJob.java

示例12: getDocType

import org.apache.xmlbeans.XmlObject; //導入依賴的package包/類
/**
 * TODO: There's gotta be a better way
 */
public String getDocType(Object docObj) {
    if (docObj instanceof String || docObj instanceof StringDocument)
        return StringDocument.class.getName();
    else if (docObj instanceof XmlObject)
        return XmlObject.class.getName();
    else if (docObj instanceof XmlBeanWrapper)
        return XmlBeanWrapper.class.getName();
    else if (docObj instanceof groovy.util.Node)
        return groovy.util.Node.class.getName();
    else if (docObj instanceof JAXBElement)
        return JAXBElement.class.getName();
    else if (docObj instanceof Document)
        return Document.class.getName();
    else if (docObj instanceof JSONObject)
        return JSONObject.class.getName();
    else if (docObj.getClass().getName().equals("org.apache.camel.component.cxf.CxfPayload"))
        return "org.apache.camel.component.cxf.CxfPayload";
    else if (docObj instanceof Jsonable)
        return Jsonable.class.getName();
    else if (docObj instanceof Yaml)
        return Yaml.class.getName();
    else
        return Object.class.getName();

}
 
開發者ID:CenturyLinkCloud,項目名稱:mdw,代碼行數:29,代碼來源:WorkflowServicesImpl.java

示例13: getProcessExecutionPlan

import org.apache.xmlbeans.XmlObject; //導入依賴的package包/類
protected ProcessExecutionPlanDocument getProcessExecutionPlan()
        throws ActivityException, XmlException {
    String plan_varname = getAttributeValue(EXECUTION_PLAN_VARIABLE);
    Object binding = this.getParameterValue(plan_varname);
    if (binding==null || ! (binding instanceof DocumentReference))
        throw new ActivityException("InvokeHeterogenenousProcess: "
                + "control variable is not bound to a process plan");
    DocumentReference docref = (DocumentReference)binding;
    binding = super.getDocumentForUpdate(docref, getParameterType(plan_varname));
    if  (binding instanceof ProcessExecutionPlanDocument) {
        return (ProcessExecutionPlanDocument)binding;
    } else if (binding instanceof XmlObject) {
        return (ProcessExecutionPlanDocument)((XmlObject)binding).changeType(ProcessExecutionPlanDocument.type);
    } else {
        Variable docVar = getProcessDefinition().getVariable(plan_varname);
        XmlDocumentTranslator docRefTrans = (XmlDocumentTranslator)VariableTranslator.getTranslator(getPackage(), docVar.getType());
        Document doc = docRefTrans.toDomDocument(binding);
        return ProcessExecutionPlanDocument.Factory.parse(doc, Compatibility.namespaceOptions());
    }
}
 
開發者ID:CenturyLinkCloud,項目名稱:mdw,代碼行數:21,代碼來源:InvokeHeterogeneousProcessActivity.java

示例14: removeHyperlink

import org.apache.xmlbeans.XmlObject; //導入依賴的package包/類
public static void removeHyperlink(XSLFTextRun textRun) {
	XmlObject xml = textRun.getXmlObject();
	if (xml instanceof CTTextField) {
		CTTextField tf = (CTTextField) xml;
		if (tf.isSetRPr()) {
			tf.getRPr().unsetHlinkClick();
		}
	} else if (xml instanceof CTTextLineBreak) {
		CTTextLineBreak tlb = (CTTextLineBreak) xml;
		if (tlb.isSetRPr()) {
			tlb.getRPr().unsetHlinkClick();
		}
	} else if (xml instanceof CTRegularTextRun) {
		CTRegularTextRun tr = (CTRegularTextRun) xml;
		if (tr.isSetRPr()) {
			tr.getRPr().unsetHlinkClick();
		}
	}
}
 
開發者ID:Coreoz,項目名稱:PPT-Templates,代碼行數:20,代碼來源:PptPoiBridge.java

示例15: addSection

import org.apache.xmlbeans.XmlObject; //導入依賴的package包/類
public XmlObjectBuilder addSection(String sectionName, XmlObject section){
    cursor.beginElement(sectionName);
    cursor.push();
    XmlCursor srcCursor = section.newCursor();
    srcCursor.toNextToken();
    while(srcCursor.currentTokenType() != XmlCursor.TokenType.NONE && srcCursor.currentTokenType() !=  XmlCursor.TokenType.ENDDOC){
        srcCursor.copyXml(cursor);
        if(srcCursor.currentTokenType() == XmlCursor.TokenType.START) srcCursor.toEndToken();
        srcCursor.toNextToken();

    }
    cursor.pop();
    cursor.toEndToken();
    cursor.toNextToken();
    srcCursor.dispose();

    return this;
}
 
開發者ID:SmartBear,項目名稱:ready-mqtt-plugin,代碼行數:19,代碼來源:XmlObjectBuilder.java


注:本文中的org.apache.xmlbeans.XmlObject類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。