本文整理了Java中org.eclipse.xsd.XSDSchema.getElement()
方法的一些代码示例,展示了XSDSchema.getElement()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XSDSchema.getElement()
方法的具体详情如下:
包路径:org.eclipse.xsd.XSDSchema
类名称:XSDSchema
方法名:getElement
[英]Returns the value of the 'Element Declarations' reference list. The list contents are of type org.eclipse.xsd.XSDElementDeclaration.
This represents the element declarations infoset property. It is computed from the #getContents() and should typically not be set directly.
[中]
代码示例来源:origin: geotools/geotools
/**
* Encode the provided SimpleFeatureType into an XSD file, using a target namespace
*
* <p>When encoding the simpleFeatureType:
*
* <ul>
* <li>target prefix/namespace can be provided by prefix and namespace parameters. This is the
* default for the entire XSD document.
* <li>simpleFeatureType.geName().getNamespaceURI() is used for the simpleFeatureType itself,
* providing simpleFeatureType.getUserData().get("prefix") is defined
* </ul>
*
* @param simpleFeatureType To be encoded as an XSD document
* @param prefix Prefix to use for for target namespace
* @param namespace Target namespace
*/
public void encode(OutputStream out, SimpleFeatureType simpleFeatureType) throws IOException {
XSDSchema xsd = xsd(simpleFeatureType);
XSDResourceImpl.serialize(out, xsd.getElement(), encoding.name());
}
代码示例来源:origin: org.eclipse/org.eclipse.wst.xsd.ui
protected XSDParticle createXSDElementReference()
{
List list = xsdModelGroup.getSchema().getElementDeclarations();
XSDElementDeclaration referencedElement = null;
if (list.size() > 0)
{
referencedElement = (XSDElementDeclaration)list.get(0);
}
else
{
referencedElement = createGlobalXSDElementDeclaration();
Text textNode = xsdSchema.getDocument().createTextNode("\n"); //$NON-NLS-1$
xsdSchema.getElement().appendChild(textNode);
xsdSchema.getContents().add(referencedElement);
}
XSDElementDeclaration element = XSDFactory.eINSTANCE.createXSDElementDeclaration();
element.setResolvedElementDeclaration(referencedElement);
XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
particle.setContent(element);
addedXSDConcreteComponent = element;
return particle;
}
代码示例来源:origin: org.eclipse/org.eclipse.xsd
/**
* Assigns diagnostics to a schema.
* @param xsdSchema the schema.
* @param xsdDiagnostics the {@link XSDDiagnostic}s.
*/
protected static void assignDiagnostics(XSDSchema xsdSchema, Collection<XSDDiagnostic> xsdDiagnostics)
{
if (!xsdDiagnostics.isEmpty())
{
xsdSchema.getDiagnostics().addAll(xsdDiagnostics);
for (XSDDiagnostic xsdDiagnostic : xsdDiagnostics)
{
xsdDiagnostic.getComponents().add(xsdSchema);
if (xsdSchema.getElement() != null)
{
xsdDiagnostic.setNode(xsdSchema.getElement());
}
}
}
}
代码示例来源:origin: org.eclipse.xsd/org.eclipse.xsd
/**
* Assigns diagnostics to a schema.
* @param xsdSchema the schema.
* @param xsdDiagnostics the {@link XSDDiagnostic}s.
*/
protected static void assignDiagnostics(XSDSchema xsdSchema, Collection<XSDDiagnostic> xsdDiagnostics)
{
if (!xsdDiagnostics.isEmpty())
{
xsdSchema.getDiagnostics().addAll(xsdDiagnostics);
for (XSDDiagnostic xsdDiagnostic : xsdDiagnostics)
{
xsdDiagnostic.getComponents().add(xsdSchema);
if (xsdSchema.getElement() != null)
{
xsdDiagnostic.setNode(xsdSchema.getElement());
}
}
}
}
代码示例来源:origin: org.eclipse/org.eclipse.wst.xsd.ui
public void updateMapAfterDelete(XSDImport deletedNode)
{
String ns = deletedNode.getNamespace();
if (ns != null)
{
String prefix = getPrefix(ns, false);
if (prefix != null)
{
prefix = prefix.trim();
}
String xmlnsAttr = (prefix == "") ? "xmlns" : "xmlns:" + prefix;
if (prefix == "")
{
prefix = null;
}
if (xsdSchema != null)
{
Map map = xsdSchema.getQNamePrefixToNamespaceMap();
map.remove(prefix);
Element schemaElement = xsdSchema.getElement();
schemaElement.removeAttribute(xmlnsAttr);
}
}
}
代码示例来源:origin: org.eclipse.xsd/org.eclipse.xsd
@Override
public EObject getEObject(String uriFragment)
{
// Do ID-based lookup.
//
if (!uriFragment.startsWith("/"))
{
Element theElement = getSchema().getElement();
if (theElement != null)
{
// Navigate out through the elements.
//
Element resultElement = theElement.getOwnerDocument().getElementById(uriFragment);
List<Element> parents = new ArrayList<Element>();
for (Node parent = resultElement; parent != null; parent = parent.getParentNode())
{
if (parent.getNodeType() == Node.ELEMENT_NODE)
{
parents.add((Element)parent);
}
}
return ((org.eclipse.xsd.impl.XSDSchemaImpl)getSchema()).getBestConcreteComponent(parents);
}
}
return super.getEObject(uriFragment);
}
代码示例来源:origin: org.eclipse/org.eclipse.xsd
@Override
public EObject getEObject(String uriFragment)
{
// Do ID-based lookup.
//
if (!uriFragment.startsWith("/"))
{
Element theElement = getSchema().getElement();
if (theElement != null)
{
// Navigate out through the elements.
//
Element resultElement = theElement.getOwnerDocument().getElementById(uriFragment);
List<Element> parents = new ArrayList<Element>();
for (Node parent = resultElement; parent != null; parent = parent.getParentNode())
{
if (parent.getNodeType() == Node.ELEMENT_NODE)
{
parents.add((Element)parent);
}
}
return ((org.eclipse.xsd.impl.XSDSchemaImpl)getSchema()).getBestConcreteComponent(parents);
}
}
return super.getEObject(uriFragment);
}
代码示例来源:origin: org.eclipse/org.eclipse.wst.xsd.ui
public void execute()
{
try
{
super.execute();
// Add this after if we don't have a DOM Node yet
beginRecording(xsdSchema.getElement());
XSDImport xsdImport = XSDFactory.eINSTANCE.createXSDImport();
xsdSchema.getContents().add(findNextPositionToInsert(), xsdImport);
addedXSDConcreteComponent = xsdImport;
formatChild(xsdSchema.getElement());
}
finally
{
endRecording();
}
}
}
代码示例来源:origin: org.eclipse/org.eclipse.wst.xsd.ui
public void doWidgetSelected(SelectionEvent e)
{
if (e.widget == editButton)
{
XSDEditNamespacesAction nsAction = new XSDEditNamespacesAction(XSDEditorPlugin.getXSDString("_UI_ACTION_EDIT_NAMESPACES"), xsdSchema.getElement(), null, xsdSchema); //$NON-NLS-1$
nsAction.run();
refresh();
}
}
代码示例来源:origin: org.eclipse/org.eclipse.wst.xsd.ui
/** Create a namespace prefix if needed, other wise retrieve
* a predefined namespace prefix
* @return */
private String handleNamespacePrefices()
{
Element schemaElement = component.getSchema().getElement();
String prefix = null;
// If target namespace of the attribute already exists
List namespacePrefices = manager.getNamespaceInfoList(schemaElement);
for (int i = 0; i < namespacePrefices.size(); i++){
NamespaceInfo info = (NamespaceInfo) namespacePrefices.get(i);
if ( info.uri.equals(attribute.getTargetNamespace())) {
prefix = info.prefix;
}
}
// Create unquie namespace prefix
if ( prefix == null){
prefix = createUniquePrefix(component);
}
NamespaceInfo info = new NamespaceInfo(attribute.getTargetNamespace(), prefix, ""); //$NON-NLS-1$
List infoList = new ArrayList(1);
infoList.add(info);
manager.addNamespaceInfo(schemaElement, infoList, false);
return prefix;
}
代码示例来源:origin: org.eclipse/org.eclipse.wst.xsd.ui
public void execute()
{
super.execute();
try
{
// Add this after if we don't have a DOM Node yet
beginRecording(xsdSchema.getElement());
XSDRedefine xsdRedefine = XSDFactory.eINSTANCE.createXSDRedefine();
xsdRedefine.setSchemaLocation(""); //$NON-NLS-1$
xsdSchema.getContents().add(findNextPositionToInsert(), xsdRedefine);
addedXSDConcreteComponent = xsdRedefine;
formatChild(xsdSchema.getElement());
}
finally
{
endRecording();
}
}
代码示例来源:origin: org.eclipse/org.eclipse.wst.xsd.ui
public void execute()
{
try
{
super.execute();
// Add this after if we don't have a DOM Node yet
beginRecording(xsdSchema.getElement());
XSDInclude xsdInclude = XSDFactory.eINSTANCE.createXSDInclude();
xsdInclude.setSchemaLocation(""); //$NON-NLS-1$
xsdSchema.getContents().add(findNextPositionToInsert(), xsdInclude);
addedXSDConcreteComponent = xsdInclude;
formatChild(xsdSchema.getElement());
}
finally
{
endRecording();
}
}
}
代码示例来源:origin: org.eclipse/org.eclipse.wst.xsd.ui
protected XSDAttributeDeclaration createGlobalXSDAttributeDeclaration(XSDSchema xsdSchema)
{
ensureSchemaElement(xsdSchema);
XSDAttributeDeclaration attribute = XSDFactory.eINSTANCE.createXSDAttributeDeclaration();
attribute.setTypeDefinition(xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("string")); //$NON-NLS-1$
attribute.setName(XSDCommonUIUtils.createUniqueElementName("NewAttribute", xsdSchema.getAttributeDeclarations())); //$NON-NLS-1$
Text textNode = xsdSchema.getDocument().createTextNode("\n"); //$NON-NLS-1$
xsdSchema.getElement().appendChild(textNode);
xsdSchema.getContents().add(attribute);
return attribute;
}
代码示例来源:origin: org.eclipse/org.eclipse.wst.xsd.ui
protected void addExtensionNode()
{
XSDAnnotation xsdAnnotation = XSDCommonUIUtils.getInputXSDAnnotation(component, true);
XSDSchema schema= xsdAnnotation.getSchema();
Element schemaElement = schema.getElement();
if (xsdAnnotation.getApplicationInformation().size() == 0)
{
appInfo = xsdAnnotation.createApplicationInformation(null);
xsdAnnotation.getElement().appendChild(appInfo);
List appInfos = xsdAnnotation.getApplicationInformation();
appInfos.add(appInfo);
}
else
{
// use the first appInfo
appInfo = (Element)xsdAnnotation.getApplicationInformation().get(0);
}
if (appInfo != null)
{
Document doc = appInfo.getOwnerDocument();
String prefix = addToNamespaceTable(schemaElement);
newElement = doc.createElementNS(extensionsSchemaSpec.getNamespaceURI(), element.getName());
newElement.setPrefix(prefix);
appInfo.appendChild(newElement);
xsdAnnotation.updateElement();
}
}
代码示例来源:origin: org.eclipse/org.eclipse.xsd
protected void doSave(Writer writer, Map<?, ?> options) throws IOException
{
XSDSchema xsdSchema = getSchema();
if (xsdSchema != null)
{
Document document = xsdSchema.getDocument();
if (document == null)
{
xsdSchema.updateDocument();
document = xsdSchema.getDocument();
}
if (xsdSchema.getElement() == null)
{
xsdSchema.updateElement();
}
doSerialize(writer, document, options);
}
}
代码示例来源:origin: org.geoserver/gs-wfs
protected void doWrite(
FeatureTypeInfo[] featureTypeInfos, OutputStream output, Operation describeFeatureType)
throws IOException {
// create the schema
Object request = describeFeatureType.getParameters()[0];
DescribeFeatureTypeRequest req = DescribeFeatureTypeRequest.adapt(request);
XSDSchema schema = schemaBuilder.build(featureTypeInfos, req.getBaseURL());
// serialize
schema.updateElement();
final String encoding = gs.getSettings().getCharset();
XSDResourceImpl.serialize(output, schema.getElement(), encoding);
}
代码示例来源:origin: org.eclipse.xsd/org.eclipse.xsd
protected void doSave(Writer writer, Map<?, ?> options) throws IOException
{
XSDSchema xsdSchema = getSchema();
if (xsdSchema != null)
{
Document document = xsdSchema.getDocument();
if (document == null)
{
xsdSchema.updateDocument();
document = xsdSchema.getDocument();
}
if (xsdSchema.getElement() == null)
{
xsdSchema.updateElement();
}
doSerialize(writer, document, options);
}
}
代码示例来源:origin: org.eclipse/org.eclipse.wst.xsd.ui
protected XSDModelGroupDefinition createXSDModelGroupDefinition()
{
XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory();
XSDModelGroupDefinition def = factory.createXSDModelGroupDefinition();
List list = parent.getSchema().getModelGroupDefinitions();
String newName = XSDCommonUIUtils.createUniqueElementName("ModelGroupDefinition", list); //$NON-NLS-1$
def.setName(newName);
XSDModelGroup modelGroup = createModelGroup();
def.setModelGroup(modelGroup);
Text textNode = parent.getSchema().getDocument().createTextNode("\n"); //$NON-NLS-1$
parent.getSchema().getElement().appendChild(textNode);
parent.getSchema().getContents().add(def);
formatChild(def.getElement());
return def;
}
代码示例来源:origin: org.eclipse.xsd/org.eclipse.xsd
@Override
protected void doSave(OutputStream os, Map<?, ?> options) throws IOException
{
if (os instanceof URIConverter.WriteableOutputStream)
{
doSave(((URIConverter.WriteableOutputStream)os).asWriter(), options);
}
else
{
XSDSchema xsdSchema = getSchema();
if (xsdSchema != null)
{
Document document = xsdSchema.getDocument();
if (document == null)
{
xsdSchema.updateDocument();
document = xsdSchema.getDocument();
}
if (xsdSchema.getElement() == null)
{
xsdSchema.updateElement();
}
doSerialize(os, document, options);
}
}
}
代码示例来源:origin: org.eclipse/org.eclipse.xsd
@Override
protected void doSave(OutputStream os, Map<?, ?> options) throws IOException
{
if (os instanceof URIConverter.WriteableOutputStream)
{
doSave(((URIConverter.WriteableOutputStream)os).asWriter(), options);
}
else
{
XSDSchema xsdSchema = getSchema();
if (xsdSchema != null)
{
Document document = xsdSchema.getDocument();
if (document == null)
{
xsdSchema.updateDocument();
document = xsdSchema.getDocument();
}
if (xsdSchema.getElement() == null)
{
xsdSchema.updateElement();
}
doSerialize(os, document, options);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!