コード例 #1
0
  protected Object[] getXSDSchemaChildren(XSDSchema schema) {
    List<XSDElementDeclaration> declarations = new ArrayList<XSDElementDeclaration>();

    List<Object> attributeDeclarations = new ArrayList<Object>();
    if (null != xsdSchema) {
      for (XSDSchemaContent cnt : xsdSchema.getContents()) {
        if (cnt instanceof XSDInclude) {
          XSDInclude incu = (XSDInclude) cnt;
          String schemaLocation = incu.getSchemaLocation();
          XSDSchema schemaInc = createSchema(schemaLocation);
          addElementDeclarationFromSchema(schemaInc, declarations);
        } else if (cnt instanceof XSDAttributeDeclaration) {
          XSDAttributeDeclaration attriDec = (XSDAttributeDeclaration) cnt;
          attributeDeclarations.add(attriDec);
        }
      }
    }
    addElementDeclarationFromSchema(schema, declarations);

    Object[] schemaChildren =
        Util.filterOutDuplicatedElems(
            declarations.toArray(new XSDNamedComponent[declarations.size()]));
    attributeDeclarations.addAll(Arrays.asList(schemaChildren));

    return attributeDeclarations.toArray();
  }
コード例 #2
0
 protected void commitDocumentToHistory(Document history) {
   try {
     String value = Util.nodeToString(history);
     undoActionTrack.put(getActionUndoPos(), value);
   } catch (Exception e) {
     log.error(e.getMessage(), e);
   }
 }
コード例 #3
0
  public void setXsdSchema(String xsd) {
    try {
      xsdSchema = Util.createXsdSchema(xsd, treeObj);
    } catch (Exception e) {

      log.error(e.getMessage(), e);
    }
  }
コード例 #4
0
 protected void commitDocumentToCurrent(Document currnt) {
   try {
     String value = Util.nodeToString(currnt);
     redoActionTrack.keySet().size();
     redoActionTrack.put(getActionUndoPos(), value);
   } catch (Exception e) {
     log.error(e.getMessage(), e);
   }
 }
コード例 #5
0
 private void refresh(String content) {
   XSDSchema xsd;
   try {
     xsd = Util.createXsdSchema(content, page.getXObject());
   } catch (Exception e) {
     log.error(e.getMessage(), e);
     return;
   }
   page.setXsdSchema(xsd);
   page.refresh();
   page.markDirtyWithoutCommit();
 }
コード例 #6
0
  protected Object[] getXSDElementDeclarationChildren_TypeDef(XSDElementDeclaration parent) {

    ArrayList<Object> list = new ArrayList<Object>();

    if (parent.getTypeDefinition() == null) {
      return new Object[0]; // elements with not type declaration
    }

    // handle extensions and restrictions directly
    if (parent.getTypeDefinition() instanceof XSDComplexTypeDefinition) {
      list.addAll(
          Util.getComplexTypeDefinitionChildren(
              (XSDComplexTypeDefinition) parent.getTypeDefinition(), true));
    } else {
      list.addAll(
          Util.getSimpleTypeDefinitionChildren(
              (XSDSimpleTypeDefinition) parent.getTypeDefinition()));
    }

    return list.toArray();
  }
コード例 #7
0
  private Object[] getXSDSimpleTypeDefinitionChildren_ATOMIC(XSDSimpleTypeDefinition parent) {
    ArrayList<Object> list = new ArrayList<Object>();
    // add Base Type if not a pre-defined type
    if (parent != null
        && parent.getSchema() != null
        && parent.getSchema().getSchemaForSchema() != null) {
      if (!parent.getSchema().getSchemaForSchema().getTypeDefinitions().contains(parent)) {
        list.add(parent.getBaseTypeDefinition());
      }
    }

    if (!Util.isBuildInType(parent)) {
      list.addAll(parent.getFacetContents());
    }

    return list.toArray(new Object[list.size()]);
  }
コード例 #8
0
  public String getXSDSchemaAsString() throws Exception {

    if (xsdSchema == null) {
      return ""; //$NON-NLS-1$
    }

    Document document = xsdSchema.getDocument();
    String schema = Util.nodeToString(document);

    // FIXES a bug in the XSD library that puts nillable attributes in
    // elements which are ref
    // That is illegal according to W3C §3.3.3 / 2.2 (and Xerces)
    Pattern p =
        Pattern.compile(
            "(<([a-z]+:)?element.*?)nillable=['|\"].*?['|\"](.*?ref=.*?>)"); //$NON-NLS-1$
    schema = p.matcher(schema).replaceAll("$1 $3"); // $NON-NLS-1$

    return schema;
  }