Package com.xmlit.project.engine.struct

Examples of com.xmlit.project.engine.struct.Struct


  }

  public static Struct getStruct(TreeGrid treeGrid, TreeNode rootNode,
      Struct parent) {
    Struct current = null;
    if (Main.Sequence.equals(rootNode.getAttribute(Type))) {
      current = new StructSequenceImpl(rootNode.getAttribute(Name));
      ((StructSequenceImpl) current).setDelimiter(handleEscape(rootNode
          .getAttribute(Delimiter)));
      ((StructSequenceImpl) current).setLookahead(handleEscape(rootNode
          .getAttribute(Lookahead)));

      ((StructSequenceImpl) current).setNegative(rootNode
          .getAttributeAsBoolean(Not));

    } else if (Main.Choice.equals(rootNode.getAttribute(Type))) {
      current = new StructChoiceImpl(rootNode.getAttribute(Name));
    } else {
      current = new StructSimpleImpl(rootNode.getAttribute(Name));
      ((StructSimpleImpl) current).setSimplePattern(handleEscape(rootNode
          .getAttribute(Regex)));
      ((StructSimpleImpl) current).setAllowedChars(handleEscape(rootNode
          .getAttribute(AllowedChars)));
      ((StructSimpleImpl) current).setAllowedValues(handleEscape(rootNode
          .getAttribute(AllowedValues)));
      if (rootNode.getAttribute(minLength) != null)
        ((StructSimpleImpl) current).setMinLength(Integer
            .parseInt(rootNode.getAttribute(minLength)));
      if (rootNode.getAttribute(maxLength) != null)
        ((StructSimpleImpl) current).setMaxLength(Integer
            .parseInt(rootNode.getAttribute(maxLength)));
    }
    if (parent != null) {
      parent.addChild(current);
    }
    if (rootNode.getAttributeAsDouble(Min) != null)
      current.setMinOccurrences(rootNode.getAttributeAsDouble(Min)
          .intValue());
    if (rootNode.getAttributeAsDouble(Max) != null)
      current.setMaxOccurrences(rootNode.getAttributeAsDouble(Max)
          .intValue());

    current.setPrefix(handleEscape(rootNode.getAttribute(Prefix)));
    current.setSuffix(handleEscape(rootNode.getAttribute(Suffix)));

    for (TreeNode node : treeGrid.getTree().getChildren(rootNode)) {
      getStruct(treeGrid, node, current);
    }
View Full Code Here


    XSElement root = xsSchema.getElements()[0];
    return readElement(root);
  }

  public static Struct readElement(XSElement element) throws Exception {
    Struct current = null;
    if (element.getType().isSimple()) {
      current = new StructSimpleImpl(element.getName().getLocalName());
      if (element.getType().getSimpleType().getPattern() != null) {
        String pattern = element.getType().getSimpleType().getPattern()[0][0];
        ((StructSimple) current)
            .setSimplePattern(handleUnEscape(pattern));
      } else {
        StringBuffer sb = new StringBuffer();
        for (XSEnumeration enu:element.getType().getSimpleType().getEnumerations()) {
          sb.append(enu.getValue() + "\n");
        }
        ((StructSimple) current).setAllowedValues(sb.toString());
      }
    } else {
      XSGroup group = element.getType().getComplexType().getParticle()
          .getGroup();

      if ("sequence".equals("" + group.getCompositor())) {
        current = new StructSequenceImpl(element.getName()
            .getLocalName());
      } else if ("choice".equals("" + group.getCompositor())) {
        current = new StructChoiceImpl(element.getName().getLocalName());
      } else if ("all".equals("" + group.getCompositor())) {
        throw new RuntimeException("'all' is not supported yet");
      }

      for (XSParticle child : group.getParticles()) {
        if (child.isElement())
          current.addChild(readElement(child.getElement()));
      }
    }
    XsTElement xele = getXsTElement(element);
    current.setMinOccurrences(xele.getMinOccurs());

    if (xele.getMaxOccurs() == -1) {
      current.setMaxOccurrences(100);
    } else {
      current.setMaxOccurrences(xele.getMaxOccurs());
    }
    handleAnnotation(current, element);

    return current;
  }
View Full Code Here

  ":97A::TAXE//x\r\n"+
  ":16S:CSHPRTY1\r\n"+
  ":16S:CASHSET1";
  public static void main(String[] args) throws Exception {
    KXSDReader reader = new KXSDReader();
    Struct root = reader.readSchema(MultiMessageTest.file2String(new File("c:/formats/fin.505.2008.xsd")));
   
    DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();

    DOMImplementationLS impl =
        (DOMImplementationLS)registry.getDOMImplementation("LS");
View Full Code Here

      String xsd = file2String(new File("C:/formats/fin."+pref+".2008.xsd"));
      //if (!xsd.equals("C:/formats/fin.700.2008.xsd")) continue;
      System.out.println(messages[i]);

      KXSDReader reader = new KXSDReader();
      Struct root=null;
      try {
        root = reader.readSchema(xsd);
      } catch (Throwable e1) {
        e1.printStackTrace();
        System.out.println("##########");
View Full Code Here

    XSElement root = xsSchema.getElements()[0];
    return readElement(root);
  }

  public static Struct readElement(XSElement element) throws Exception {
    Struct current = null;
    boolean mandatory = true;
    if (element.getType().isSimple()) {
      current = new StructSimpleImpl(element.getName().getLocalName());
      mandatory = handleSimple((StructSimple) current, element);
      // System.out.println(element.getName() + "  "
      // +element.getType().getSimpleType().getPattern());
    } else {
      XSGroup group = element.getType().getComplexType().getParticle()
          .getGroup();

      if ("sequence".equals("" + group.getCompositor())) {
        current = new StructSequenceImpl(element.getName()
            .getLocalName());
        mandatory = handleSequence((StructSequence) current, element);
      } else if ("choice".equals("" + group.getCompositor())) {
        current = new StructChoiceImpl(element.getName().getLocalName());
      } else if ("all".equals("" + group.getCompositor())) {
        throw new RuntimeException("Choice is not supported yet");
      }

      // System.out.println(element.getName());
      for (XSParticle child : group.getParticles()) {
        current.addChild(readElement(child.getElement()));
      }
    }
    XsTElement xele = getXsTElement(element);
    if (mandatory) {
      current.setMinOccurrences(xele.getMinOccurs());
    } else {
      current.setMinOccurrences(0);
    }
    if (xele.getMaxOccurs() == -1) {
      current.setMaxOccurrences(100);
    } else {
      current.setMaxOccurrences(xele.getMaxOccurs());
    }

    return current;
  }
View Full Code Here

TOP

Related Classes of com.xmlit.project.engine.struct.Struct

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.