protected void createUserInfo(XSDAnnotation xsdAnnotation, String documentation) { Element userInformation = xsdAnnotation.createUserInformation(null); // Try to parse the documentation and use the parsed version if it's successful. // XSDParser xsdParser = new XSDParser(null); xsdParser.parseString("<documentation>" + documentation + "</documentation>"); Document document = xsdParser.getDocument(); if (xsdParser.getDiagnostics().isEmpty() && document.getDocumentElement().getFirstChild() != null) { Document xsdDocument = xsdAnnotation.getSchema().getDocument(); for (Node node = document.getDocumentElement().getFirstChild(); node != null; node = node.getNextSibling()) { userInformation.appendChild(xsdDocument.importNode(node, true)); } } else { userInformation.appendChild(xsdAnnotation.getSchema().getDocument().createTextNode(documentation)); } xsdAnnotation.getElement().appendChild(userInformation); }
protected void createUserInfo(XSDAnnotation xsdAnnotation, String documentation) { Element userInformation = xsdAnnotation.createUserInformation(null); // Try to parse the documentation and use the parsed version if it's successful. // XSDParser xsdParser = new XSDParser(null); xsdParser.parseString("<documentation>" + documentation + "</documentation>"); Document document = xsdParser.getDocument(); if (xsdParser.getDiagnostics().isEmpty() && document.getDocumentElement().getFirstChild() != null) { Document xsdDocument = xsdAnnotation.getSchema().getDocument(); for (Node node = document.getDocumentElement().getFirstChild(); node != null; node = node.getNextSibling()) { userInformation.appendChild(xsdDocument.importNode(node, true)); } } else { userInformation.appendChild(xsdAnnotation.getSchema().getDocument().createTextNode(documentation)); } xsdAnnotation.getElement().appendChild(userInformation); }
protected XSDAttributeDeclaration setGlobalAttributeReference(XSDSchema xsdSchema) { List list = xsdSchema.getAttributeDeclarations(); XSDAttributeDeclaration referencedAttribute = null; boolean isUserDefined = false; for (Iterator i = list.iterator(); i.hasNext(); ) { Object obj = i.next(); if (obj instanceof XSDAttributeDeclaration) { XSDAttributeDeclaration attr = (XSDAttributeDeclaration) obj; if (!XSDConstants.SCHEMA_INSTANCE_URI_2001.equals(attr.getTargetNamespace())) { referencedAttribute = attr; isUserDefined = true; break; } } } if (!isUserDefined) { referencedAttribute = createGlobalXSDAttributeDeclaration(xsdSchema); Text textNode = xsdSchema.getDocument().createTextNode("\n"); //$NON-NLS-1$ xsdSchema.getElement().appendChild(textNode); xsdSchema.getContents().add(referencedAttribute); } return referencedAttribute; }
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); } }
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); } }
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; }
document = xsdSchema.getDocument(); if (document == null)
applicationInformation = (Element)xsdAnnotation.getApplicationInformation().get(xsdAnnotation.getApplicationInformation().size() - 1).getLastChild(); Document document = xsdSchema.getDocument(); for (ETypeParameter eTypeParameter : eTypeParameters)
applicationInformation = (Element)xsdAnnotation.getApplicationInformation().get(xsdAnnotation.getApplicationInformation().size() - 1).getLastChild(); Document document = xsdSchema.getDocument(); for (ETypeParameter eTypeParameter : eTypeParameters)
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; }
@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); } } }
@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); } } }
private void adopt(XSDSchema xsdSchema) { Definition definition = getEnclosingDefinition(); if (definition == null) return; Document document = definition.getDocument(); if (document == null) document = ((DefinitionImpl)definition).updateDocument(); if (xsdSchema.getDocument() != null) xsdSchema.setDocument(null); xsdSchema.setDocument(document); }
protected static void ensureSchemaElement(XSDSchema schema) { Document document = schema.getDocument(); Element schemaElement = document.getDocumentElement(); if (schemaElement == null) { String targetNamespace = getDefaultNamespace(schema); schema.setTargetNamespace(targetNamespace); Map qNamePrefixToNamespaceMap = schema.getQNamePrefixToNamespaceMap(); qNamePrefixToNamespaceMap.put("tns", targetNamespace); if (XSDEditorPlugin.getDefault().isQualifyXMLSchemaLanguage()) { String prefix = XSDEditorPlugin.getDefault().getXMLSchemaPrefix(); schema.setSchemaForSchemaQNamePrefix(prefix); qNamePrefixToNamespaceMap.put(prefix, XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001); } else { qNamePrefixToNamespaceMap.put(null, XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001); } schema.updateElement(); ensureXMLDirective(document); } }
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; }
applicationInformation.appendChild(xsdAnnotation.getSchema().getDocument().createTextNode(value));
applicationInformation.appendChild(xsdAnnotation.getSchema().getDocument().createTextNode(value));
Text textNode = xsdSchema.getDocument().createTextNode("\n"); //$NON-NLS-1$ xsdSchema.getElement().appendChild(textNode); xsdSchema.getContents().add(complexType);
Text textNode = xsdSchema.getDocument().createTextNode("\n"); //$NON-NLS-1$ xsdSchema.getElement().appendChild(textNode); xsdSchema.getContents().add(typeDef);
Text textNode = xsdSchema.getDocument().createTextNode("\n"); //$NON-NLS-1$ xsdSchema.getElement().appendChild(textNode); xsdSchema.getContents().add(attributeGroup);