Package uk.gov.nationalarchives.droid.core.signature.xml

Examples of uk.gov.nationalarchives.droid.core.signature.xml.SAXModelBuilder


     * @return sig file
     * @throws SignatureParseException if there is a problem parsing the signature file.
     */
    FFSignatureFile parseSigFile(String theFileName) throws SignatureParseException {

        SAXModelBuilder mb = new SAXModelBuilder();
        XMLReader parser = getXMLReader(mb);

        //read in the XML file
        try {
            BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(theFileName), "UTF-8"));
            parser.parse(new InputSource(in));
            in.close();
        } catch (IOException e) {
            throw new SignatureParseException(e.getMessage(), e);
        } catch (SAXException e) {
            throw new SignatureParseException(e.getMessage(), e);
        }
        return (FFSignatureFile) mb.getModel();
    }
View Full Code Here


       
        try {
            SAXParser saxParser = factory.newSAXParser();
            final XMLReader xmlReader = saxParser.getXMLReader();

            SAXModelBuilder mb = new SAXModelBuilder();
            xmlReader.setContentHandler(mb);
            serializer.setOutputCharStream(writer);

            serializer.serialize(element);
            final String xml = writer.getBuffer().toString();
            xmlReader.parse(new InputSource(new StringReader(xml)));
            T sig = (T) mb.getModel();
            return sig;
        } catch (ParserConfigurationException e) {
            throw new SignatureParseException(e);
        } catch (SAXException e) {
            throw new SignatureParseException(e);
View Full Code Here

       
        SAXParserFactory factory = SAXParserFactory.newInstance();
        SAXParser saxParser = factory.newSAXParser();
        final XMLReader xmlReader = saxParser.getXMLReader();

        SAXModelBuilder mb = new SAXModelBuilder();
        xmlReader.setContentHandler(mb);
        serializer.setOutputCharStream(writer);

        serializer.serialize(internalSigXml);
        xmlReader.parse(new InputSource(new StringReader(writer.getBuffer().toString())));
       
        InternalSignatureCollection sigs = (InternalSignatureCollection) mb.getModel();
        assertEquals(1, sigs.getInternalSignatures().size());
        InternalSignature sig = sigs.getInternalSignatures().get(0);
        assertEquals(2, sig.getByteSequences().size());
    }
View Full Code Here

TOP

Related Classes of uk.gov.nationalarchives.droid.core.signature.xml.SAXModelBuilder

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.