本文整理汇总了Java中org.apache.xmlbeans.XmlCursor.setName方法的典型用法代码示例。如果您正苦于以下问题:Java XmlCursor.setName方法的具体用法?Java XmlCursor.setName怎么用?Java XmlCursor.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xmlbeans.XmlCursor
的用法示例。
在下文中一共展示了XmlCursor.setName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setLocalName
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
*
* @param name
*/
void setLocalName(String localName)
{
XmlCursor cursor = newCursor();
try
{
if(cursor.isStartdoc())
cursor.toFirstContentToken();
if(cursor.isText() || cursor.isComment()) return;
javax.xml.namespace.QName qname = cursor.getName();
cursor.setName(new javax.xml.namespace.QName(
qname.getNamespaceURI(), localName, qname.getPrefix()));
}
finally
{
cursor.dispose();
}
}
示例2: setNamespace
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
*
* @param ns
*/
void setNamespace(Namespace ns)
{
XmlCursor cursor = newCursor();
try
{
if(cursor.isStartdoc())
cursor.toFirstContentToken();
if(cursor.isText() ||
cursor.isComment() ||
cursor.isProcinst()) return;
String prefix = ns.prefix();
if (prefix == null) {
prefix = "";
}
cursor.setName(new javax.xml.namespace.QName(
ns.uri(), localName(), prefix));
}
finally
{
cursor.dispose();
}
}
示例3: encodeStatisticCollection
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
private StatisticsCollectionDocument encodeStatisticCollection(StatisticCollection element) throws UnsupportedUncertaintyTypeException {
StatisticsCollectionDocument xb_scDoc = StatisticsCollectionDocument.Factory.newInstance();
StatisticsCollectionType xb_scType = xb_scDoc.addNewStatisticsCollection();
XmlCursor cursor = null;
for (int i = 0; i < element.size(); i++) {
IStatistic s = element.get(i);
AbstractSummaryStatisticType xb_cmType = xb_scType.addNewAbstractSummaryStatistic();
AbstractSummaryStatisticDocument result = encodeStatistic(s);
cursor = xb_scType.newCursor();
xb_cmType.set(result.getAbstractSummaryStatistic());
//renaming of element and removal of xsi:type attribute
String elementName = result.getClass().getSimpleName().replace("DocumentImpl", "");
cursor.toChild(new QName(NAMESPACE, "AbstractSummaryStatistic"));
cursor.setName(new QName(NAMESPACE, elementName));
cursor.removeAttribute(new QName("http://www.w3.org/2001/XMLSchema-instance", "type"));
}
return xb_scDoc;
}
示例4: qualifySubstitutionGroup
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
* Qualifies a valid member of a substitution group. This method tries to use the
* built-in {@link XmlObject#substitute(QName, SchemaType)} and if succesful returns
* a valid substitution which is usable (not disconnected). If it fails, it uses
* low-level {@link XmlCursor} manipulation to qualify the substitution group. Note
* that if the latter is the case the resulting document is disconnected and should
* no longer be manipulated. Thus, use it as a final step after all markup is included.
*
* If newType is null, this method will skip {@link XmlObject#substitute(QName, SchemaType)}
* and directly use {@link XmlCursor}. This can be used, if you are sure that the substitute
* is not in the list of (pre-compiled) valid substitutions (this is the case if a schema
* uses another schema's type as a base for elements. E.g. om:Observation uses gml:_Feature
* as the base type).
*
* @param xobj
* the abstract element
* @param newInstance
* the new {@link QName} of the instance
* @param newType the new schemaType. if null, cursors will be used and the resulting object
* will be disconnected.
* @return if successful applied {@link XmlObject#substitute(QName, SchemaType)} a living object with a
* type == newType is returned. Otherwise null is returned as you can no longer manipulate the object.
*/
public static XmlObject qualifySubstitutionGroup(XmlObject xobj, QName newInstance, SchemaType newType) {
XmlObject substitute = null;
if (newType != null) {
substitute = xobj.substitute(newInstance, newType);
if (substitute != null && substitute.schemaType() == newType
&& substitute.getDomNode().getLocalName().equals(newInstance.getLocalPart()))
{
return substitute;
}
}
XmlCursor cursor = xobj.newCursor();
cursor.setName(newInstance);
QName qName = new QName("http://www.w3.org/2001/XMLSchema-instance", "type");
cursor.removeAttribute(qName);
cursor.toNextToken();
if (cursor.isNamespace()) {
cursor.removeXml();
}
cursor.dispose();
return null;
}
示例5: qualifySubstitutionGroup
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
* Qualifies a valid member of a substitution group. This method tries to use the
* built-in {@link XmlObject#substitute(QName, SchemaType)} and if succesful returns
* a valid substitution which is usable (not disconnected). If it fails, it uses
* low-level {@link XmlCursor} manipulation to qualify the substitution group. Note
* that if the latter is the case the resulting document is disconnected and should
* no longer be manipulated. Thus, use it as a final step after all markup is included.
*
* If newType is null, this method will skip {@link XmlObject#substitute(QName, SchemaType)}
* and directly use {@link XmlCursor}. This can be used, if you are sure that the substitute
* is not in the list of (pre-compiled) valid substitutions (this is the case if a schema
* uses another schema's type as a base for elements. E.g. om:Observation uses gml:_Feature
* as the base type).
*
* @param xobj
* the abstract element
* @param newInstance
* the new {@link QName} of the instance
* @param newType the new schemaType. if null, cursors will be used and the resulting object
* will be disconnected.
* @return if successful applied {@link XmlObject#substitute(QName, SchemaType)} a living object with a
* type == newType is returned. Otherwise null is returned as you can no longer manipulate the object.
*/
public static XmlObject qualifySubstitutionGroup(XmlObject xobj, QName newInstance, SchemaType newType) {
XmlObject substitute = null;
if (newType != null) {
substitute = xobj.substitute(newInstance, newType);
if (substitute != null && substitute.schemaType() == newType
&& substitute.getDomNode().getLocalName().equals(newInstance.getLocalPart()))
{
return substitute;
}
}
XmlCursor cursor = xobj.newCursor();
cursor.setName(newInstance);
QName qName = new QName("http://www.w3.org/2001/XMLSchema-instance", "type");
cursor.removeAttribute(qName);
cursor.toNextToken();
if (cursor.isNamespace()) {
cursor.removeXml();
}
cursor.dispose();
return null;
}
示例6: changeNS
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
protected void changeNS (String oldURI, String newURI)
{
XmlCursor curs = newCursor();
while (curs.toParent()) {
/* Goto the top of the document */
}
TokenType tt = curs.currentTokenType();
if (tt.isStartdoc())
{
tt = curs.toFirstContentToken();
}
if (tt.isStart())
{
do
{
if (tt.isStart() || tt.isAttr() || tt.isNamespace())
{
javax.xml.namespace.QName currQName = curs.getName();
if (oldURI.equals(currQName.getNamespaceURI()))
{
curs.setName(new javax.xml.namespace.QName(newURI, currQName.getLocalPart()));
}
}
tt = curs.toNextToken();
} while (!tt.isEnddoc() && !tt.isNone());
}
curs.dispose();
}
示例7: setName
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
*
* @param name
*/
void setName(QName qname)
{
XmlCursor cursor = newCursor();
try
{
if(cursor.isStartdoc())
cursor.toFirstContentToken();
if(cursor.isText() || cursor.isComment()) return;
if(cursor.isProcinst())
{
String localName = qname.localName();
cursor.setName(new javax.xml.namespace.QName(localName));
}
else
{
String prefix = qname.prefix();
if (prefix == null) { prefix = ""; }
cursor.setName(new javax.xml.namespace.QName(
qname.uri(), qname.localName(), prefix));
}
}
finally
{
cursor.dispose();
}
}
示例8: encodeMixtureModel
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
private MixtureModelDocument encodeMixtureModel(MixtureModel element) throws UnsupportedUncertaintyTypeException {
MixtureModelDocument xb_mmDoc = MixtureModelDocument.Factory.newInstance();
MixtureModelType xb_mmType = xb_mmDoc.addNewMixtureModel();
XmlCursor cursor = null;
for (WeightedDistribution w : element) {
if (w.getDistribution() instanceof HypergeometricDistribution) {
System.out.println();
}
Component c = xb_mmType.addNewComponent();
c.setWeight(w.getWeight());
AbstractDistributionType adt = c.addNewAbstractDistribution();
AbstractDistributionDocument result = encodeDistribution(w.getDistribution());
cursor = c.newCursor();
adt.set(result.getAbstractDistribution());
//renaming of element and removal of xsi:type attribute
String elementName = result.getClass().getSimpleName().replace("DocumentImpl", "");
cursor.toChild(new QName(NAMESPACE, "AbstractDistribution"));
cursor.setName(new QName(NAMESPACE, elementName));
cursor.removeAttribute(new QName("http://www.w3.org/2001/XMLSchema-instance", "type"));
}
return xb_mmDoc;
}