All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jwat.tools.validators.XmlValidator.jpage Maven / Gradle / Ivy

Go to download

JWAT-Tools uses the available JWAT libraries to make high level tasks available either from command-line or programmatically. Common tasks include: Test, Compress, Decompress, CDX, Arc2Warc. More specialised tasks include: Changed, ContainerMD, Delete, Extract, Interval, PathIndex, Unpack, Headers2CDX.

There is a newer version: 0.7.1
Show newest version
    	/**
    	 * Parse an XML document without validating DTD/XSD.
    	 * @param in XML input stream
    	 */
        public void parse(InputStream in, TestFileResultItemDiagnosis itemDiagnosis) {
        	document = null;
        	try {
        		errorHandler.itemDiagnosis = itemDiagnosis;
        		builderParsing.reset();
        		builderParsing.setErrorHandler(errorHandler);
        		document = builderParsing.parse(in);
        		systemId = null;
        		DocumentType documentType = document.getDoctype();
        		if (documentType != null) {
            		systemId = documentType.getSystemId();
        		}
        		if (systemId == null) {
        			Node node = document.getDocumentElement();
        			Node attribute = node.getAttributes().getNamedItemNS("xmlns", "xsi");
        			if (attribute != null) {
        				System.out.println("xmlnsXsi: " + attribute.getNodeValue());
        			}
        		}
        		else {
        			System.out.println("systemId: " + systemId);
        		}
        	}
        	catch (Throwable t) {
        		if (itemDiagnosis != null) {
        			itemDiagnosis.throwables.add(t);
        		}
        		else {
        			t.printStackTrace();
        		}
        	}
        }

        /**
         * Parse an XML document and validate using DTD/XSD.
    	 * @param in XML input stream
         */
        public void validate(ManagedPayload managedPayload, TestFileResultItemDiagnosis itemDiagnosis) {
        	document = null;
        	try {
        		errorHandler.itemDiagnosis = itemDiagnosis;
        		builderParsing.reset();
        		builderParsing.setErrorHandler(errorHandler);
        		document = builderParsing.parse(in);
        		systemId = null;
        		DocumentType documentType = document.getDoctype();
        		if (documentType != null) {
            		systemId = documentType.getSystemId();
        		}
        		if (systemId == null) {
        			Node node = document.getDocumentElement();
        			Node attribute = node.getAttributes().getNamedItemNS("xmlns", "xsi");
        			if (attribute != null) {
        				System.out.println("xmlnsXsi: " + attribute.getNodeValue());
        			}
        		}
        		else {
        			System.out.println("systemId: " + systemId);
        		}
        	}
        	catch (Throwable t) {
        		if (itemDiagnosis != null) {
        			itemDiagnosis.throwables.add(t);
        		}
        		else {
        			t.printStackTrace();
        		}
        	}
        }

			/*
	       	document = null;
        	try {
        		errorHandler.itemDiagnosis = itemDiagnosis;
        		builderValidating.reset();
        		builderValidating.setEntityResolver(entityResolver);
        		builderValidating.setErrorHandler(errorHandler);
        		document = builderValidating.parse(in);
        	}
        	catch (Throwable t) {
        		if (itemDiagnosis != null) {
        			itemDiagnosis.throwables.add(t);
        		}
        		else {
        			t.printStackTrace();
        		}
        	}
        	*/

		/*
	    System.out.println(">" + nodes.item(i));
	    NamedNodeMap nnm = nodes.item(i).getAttributes();
	    for (int j=0; j




© 2015 - 2025 Weber Informatics LLC | Privacy Policy