Package org.milyn.edisax

Examples of org.milyn.edisax.EDIParser


  public void test() throws IOException, SAXException, EDIConfigurationException {
    MockContentHandler handler;
    EdifactModel msg1 = EDIParser.parseMappingModel(getClass().getResourceAsStream("edi-to-xml-mapping.xml"));
   
    EDIParser parser = new EDIParser();
    parser.setMappingModel(msg1);

    handler = new MockContentHandler();
    parser.setContentHandler(handler)

    parser.parse(new InputSource(getClass().getResourceAsStream("edi-input.txt")));   
   
        XMLUnit.setIgnoreWhitespace( true );
        XMLAssert.assertXMLEqual(new InputStreamReader(getClass().getResourceAsStream("expected.xml")), new StringReader(handler.xmlMapping.toString()));
  }
View Full Code Here


    public void testPackage(String packageName, String mappingModel) throws IOException, InstantiationException, IllegalAccessException, SAXException, EDIConfigurationException {
        InputStream testFileInputStream = getClass().getResourceAsStream("testfiles/" + packageName + "/input.edi");

        MockContentHandler contentHandler = new MockContentHandler();
        EDIParser parser = new EDIParser();
        parser.setContentHandler(contentHandler);
        parser.setMappingModel(EDIParser.parseMappingModel(new StringReader(mappingModel)));
        parser.parse(new InputSource(testFileInputStream));

        String expected = new String(StreamUtils.readStream(getClass().getResourceAsStream("testfiles/" + packageName + "/expected-result.xml"))).trim();
        String actual = contentHandler.xmlMapping.toString();

//        System.out.println(actual);
View Full Code Here

            // ignore verifing that the exception content is correct
        }
    }

    private void parseEdiMessage(String inputFile) throws IOException, SAXException, EDIParseException {
        EDIParser parser = new EDIParser();
        parser.setMappingModel(msg1);
        parser.setContentHandler(handler);
        parser.parse(new InputSource(getClass().getResourceAsStream(inputFile)));
    }
View Full Code Here

        this.features = parserFeatures;
        this.controlBlockHandlerFactory = controlBlockHandlerFactory;
    this.validate = validate;
        this.namespaceDeclarationStack = namespaceDeclarationStack;

    controlSegmentParser = new EDIParser();
    controlSegmentParser.setBufferedSegmentReader(segmentReader);
    controlSegmentParser.setContentHandler(contentHandler);
    controlSegmentParser.setIndentDepth(indentDepth);

        if (this.namespaceDeclarationStack == null) {
View Full Code Here

    public NamespaceDeclarationStack getNamespaceDeclarationStack() {
        return namespaceDeclarationStack;
    }

    public EDIParser newParser(EdifactModel mappingModel) {
    EDIParser parser = new EDIParser();

    parser.setContentHandler(contentHandler);
    parser.setMappingModel(mappingModel);
    parser.setBufferedSegmentReader(segmentReader);
    parser.setIndentDepth(indentDepth);
        parser.getFeatures().putAll(features);
    parser.setFeature(EDIParser.FEATURE_VALIDATE, validate);
        parser.setNamespaceDeclarationStack(namespaceDeclarationStack);

    return parser;
  }
View Full Code Here

  public void test() throws IOException, SAXException, EDIConfigurationException {
    MockContentHandler handler;
    EdifactModel msg1 = EDIParser.parseMappingModel(getClass().getResourceAsStream("edi-to-xml-mapping.xml"));
   
    EDIParser parser = new EDIParser();
    parser.setMappingModel(msg1);

    handler = new MockContentHandler();
    parser.setContentHandler(handler)

    parser.parse(new InputSource(getClass().getResourceAsStream("edi-input.txt")));   
   
        XMLUnit.setIgnoreWhitespace( true );
        XMLAssert.assertXMLEqual(new InputStreamReader(getClass().getResourceAsStream("expected.xml")), new StringReader(handler.xmlMapping.toString()));
  }
View Full Code Here

    interchangeContext.getControlSegmentParser().startElement(InterchangeContext.INTERCHANGE_MESSAGE_BLOCK_ELEMENT_NAME, unhSegment.getNamespace(), true, attrs);
        interchangeContext.mapControlSegment(unhSegment, false);

    // Map the message... stopping at the UNT segment...
    try {
      EDIParser parser = interchangeContext.newParser(mappingModel);

      segmentReader.setSegmentListener(untSegmentListener);

            if(hierarchyChangeListener != null) {
                hierarchyChangeListener.attachXMLReader(parser);
            } else if (!interchangeContext.isContainerManagedNamespaceStack()) {
                interchangeContext.getNamespaceDeclarationStack().pushReader(parser);
            }

            parser.parse();
    } finally {
      segmentReader.setSegmentListener(null);
            if(hierarchyChangeListener != null) {
                hierarchyChangeListener.detachXMLReader();
            } else if (!interchangeContext.isContainerManagedNamespaceStack()) {
View Full Code Here

TOP

Related Classes of org.milyn.edisax.EDIParser

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.