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