Validar XML Assinado

3 respostas
N

Bem estou tentando validar um xml que possui uma assinatura digital, baixei o xsd setei ele mas recebo o que de que o xsd não foi encontrado.

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();  
		
		factory.setNamespaceAware(true);  
		factory.setValidating(true);
		factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");			
		factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", "C:/Projetos/xmldsig-core-schema_v1.01.xsd");
		factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", "C:/Projetos/nfe_v1.10.xsd");  
	
		DocumentBuilder builder = null;  
		try   
		{  
			builder = factory.newDocumentBuilder();  
			builder.setErrorHandler( new SimpleErrorHandler());  
		} catch (ParserConfigurationException ex)   
		{  
			ex.printStackTrace();  
		}  
		Document document;  
		try   
		{  
			document = builder.parse("C:/Projetos/625-nfe.xml");  
			rootNode  = document.getFirstChild();

Erro

schema_reference.4: Failed to read schema document 'xmldsig-core-schema_v1.01.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
src-resolve: Cannot resolve the name 'ds:Signature' to a(n) 'element declaration' component.
cvc-complex-type.2.4.d: Invalid content was found starting with element 'Signature'. No child element is expected at this point.

Este xml é valido pois validei ele pelo aplicativo da sefaz.

Alguém poderia me ajudar.

Obrigado

3 Respostas

L

o nome do arquivo não devia ser separado com \ ?

“C:\Projetos\xmldsig-core-schema_v1.01.xsd” ??

factory.setAttribute(“http://java.sun.com/xml/jaxp/properties/schemaSource”, “C:/Projetos/xmldsig-core-schema_v1.01.xsd”);

N

Lao pelo que sei \ é igual a /

Valeu

J

nandobgi,

estou com o mesmo problema…se achar a solução posta aqui pra gente

valeu

Criado 15 de maio de 2008
Ultima resposta 19 de ago. de 2008
Respostas 3
Participantes 3