Cannot resolve the name 'xmldsig:Signature' to a(n) 'element

This should cover W3C XML Schema, Relax NG and DTD related problems.
ivanpgs
Posts: 3
Joined: Wed Jun 29, 2005 2:09 pm

Cannot resolve the name 'xmldsig:Signature' to a(n) 'element

Post by ivanpgs » Wed Jun 29, 2005 2:23 pm

Hi all,

Lately I have been going through differents problems while trying to validate a XML along with a XSD schema.

The message in the subjetc: Cannot resolve the name 'xmldsig:Signature' to a(n) 'element, is produced by the next code:

XML FILE
URI="file:///C:/Ivan/Programas/eclipse/workspace/TratamientoXML/xml/PeticionFirmada.xml"

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PeticionFirmada xmlns="https://www.munimadrid.es/Pagos">
<Peticion Id="12345" Version="1.0">
<NumOperacion>1111</NumOperacion>
<NifAyuntamiento>50200203</NifAyuntamiento>
<FechaTransaccion>
<DiaTransaccion>05052005</DiaTransaccion>
<HoraTransaccion>1245</HoraTransaccion>
</FechaTransaccion>
<CanalPago>1</CanalPago>
<InfoCertificado>
<NombreCertificado>César Fernández</NombreCertificado>
<NifCertificado>50200203</NifCertificado>
<NumeroSerieCertificado>123456879</NumeroSerieCertificado>
</InfoCertificado>
<InfoCuenta>
<Entidad>1234</Entidad>
<Sucursal>1234568790</Sucursal>
<DC>12</DC>
<Cuenta>1234</Cuenta>
</InfoCuenta>
<EntidadReceptora>2038</EntidadReceptora>
<Emisor>
<NumEmisor>28984.0</NumEmisor>
<Identificador>12345</Identificador>
<FechaControl>05052005</FechaControl>
<DigitosControl>12</DigitosControl>
<ImporteCobro>0000000010</ImporteCobro>
<NIFCIFInteresado>12345678F</NIFCIFInteresado>
<Confirmacion>
<Etiqueta>Marca y modelo
</Etiqueta>
<Etiqueta>Matricula
</Etiqueta>
<Informacion>OPEN CALIBRA
</Informacion>
<Informacion>M-9900-GM
</Informacion>
</Confirmacion>
<Recibo>
<AnioyTipoPres>54321</AnioyTipoPres>
<Concepto>7654321</Concepto>
<DatosRecibo>
<Linea1>linea 1</Linea1>
<Linea2>linea 2</Linea2>
<Linea3>linea 3</Linea3>
<Linea4>linea 4</Linea4>
<Linea5>linea 5</Linea5>
<Linea6>linea 6</Linea6>
<Linea7>linea 7</Linea7>
<Linea8>linea 8</Linea8>
</DatosRecibo>
</Recibo>
</Emisor>
</Peticion>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#12345">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>TRvw0HxqIAPNfRA/comKXO0w9l8=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>
rDM8lP5IxIoEAIcsVcfBJXb+FcKYeGHAkS5S9yeLHNjZ45JtIrYbIvhp2YNqn+sTB0+MScVHe2HW
jVv9wrEGqIBpnP1zzzLxJrxrEqOP/AxlDGeYPsydOUudnuBOWaC4wKd0sFfIgzrmq7dNKunB0eoK
RvvEbweCT3NiyIHO1j8=
</ds:SignatureValue>
<ds:KeyInfo>
<ds:X509Data>
<ds:X509Certificate>
MIID4zCCA0ygAwIBAgIEPHR4dTANBgkqhkiG9w0BAQUFADA2MQswCQYDVQQGEwJFUzENMAsGA1UE
ChMERk5NVDEYMBYGA1UECxMPRk5NVCBDbGFzZSAyIENBMB4XDTAzMTEwNzEyNDQ1NloXDTA1MTEw
NzEzMTQ1NlowgbgxCzAJBgNVBAYTAkVTMQ0wCwYDVQQKEwRGTk1UMRgwFgYDVQQLEw9GTk1UIENs
YXNlIDIgQ0ExETAPBgNVBAsTCFB1YmxpY29zMRIwEAYDVQQLEw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v2ZtkuZpX3
</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
</ds:Signature>
</PeticionFirmada>

XSD MAIN FILE:
URI="file:///C:/Ivan/Programas/eclipse/workspace/TratamientoXML/xsd/PeticionPagosFirma.xsd"

<?xml version="1.0" encoding="utf-8"?>

<xs:schema xmlns:xmldsig="http://www.w3.org/2000/09/xmldsig#"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<!--
<xs:schema xmlns:xmldsig="http://www.w3.org/2000/09/xmldsig#"
xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
-->

<xs:include schemaLocation="file:///C:/Ivan/Programas/eclipse/workspace/TratamientoXML/xsd/PeticionPagos.xsd"/>
<!-- Otros schemas -->
<xs:import namespace="http://www.w3.org/2000/09/xmldsig#"/>
<!-- Element -->
<xs:element name="PeticionFirmada">
<xs:complexType>
<xs:sequence>
<xs:element ref="Peticion"/>
<xs:element ref="xmldsig:Signature" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

XSD SUPPORT FILE:
URI="file:///C:/Ivan/Programas/eclipse/workspace/TratamientoXML/xsd/PeticionPagos.xsd"
<?xml version="1.0" encoding="utf-8"?>

<xs:schema xmlns:xmldsig="http://www.w3.org/2000/09/xmldsig#"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<!--
<xs:schema xmlns:xmldsig="http://www.w3.org/2000/09/xmldsig#" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
-->
<!-- Elementos Referenciados -->
<xs:element name="Peticion">
<xs:complexType>
<xs:sequence>
<xs:element ref="NumOperacion"/>
<xs:element ref="NifAyuntamiento"/>
<xs:element ref="FechaTransaccion"/>
<xs:element ref="CanalPago"/>
<xs:element ref="InfoCertificado"/>
<xs:element ref="InfoCuenta"/>
<xs:element ref="EntidadReceptora"/>
<xs:element ref="Emisor"/>
</xs:sequence>
<xs:attribute name="Id" type="tipo_id" use="required"/>
<xs:attribute name="Version" type="tipo_version" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="NumOperacion">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="NifAyuntamiento">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="9"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="FechaTransaccion">
<xs:complexType>
<xs:sequence>
<xs:element ref="DiaTransaccion"/>
<xs:element ref="HoraTransaccion"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="DiaTransaccion">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="\d{1,8}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="HoraTransaccion">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="\d{1,4}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="CanalPago">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="1"/>
<xs:enumeration value="2"/>
<xs:enumeration value="3"/>
<xs:enumeration value="4"/>
<xs:enumeration value="5"/>
<xs:enumeration value="6"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="InfoCertificado">
<xs:complexType>
<xs:sequence>
<xs:element ref="NombreCertificado"/>
<xs:element ref="NifCertificado"/>
<xs:element ref="NumeroSerieCertificado"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="NombreCertificado">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="70"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="NifCertificado">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="NumeroSerieCertificado">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="8"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="InfoCuenta">
<xs:complexType>
<xs:sequence>
<xs:element ref="Entidad"/>
<xs:element ref="Sucursal"/>
<xs:element ref="DC"/>
<xs:element ref="Cuenta"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Entidad">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="4"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Sucursal">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="4"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="DC">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Cuenta">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="\d{1,10}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="EntidadReceptora">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="4"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Emisor">
<xs:complexType>
<xs:sequence>
<xs:element ref="NumEmisor"/>
<xs:element ref="Identificador"/>
<xs:element ref="FechaControl"/>
<xs:element ref="DigitosControl"/>
<xs:element ref="ImporteCobro"/>
<xs:element ref="NIFCIFInteresado"/>
<xs:element ref="Gestor"/>
<xs:element ref="Datos"/>
<xs:element ref="Confirmacion" minOccurs="1" maxOccurs="4"/>
<xs:element ref="Recibo" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="NumEmisor">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="28984.0"/>
<xs:enumeration value="28989.9"/>
<xs:enumeration value="28990.5"/>
<xs:enumeration value="28992.9"/>
<xs:enumeration value="28995.4"/>
<xs:enumeration value="28996.6"/>
<xs:enumeration value="28997.8"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Identificador">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="9"/>
<xs:maxLength value="17"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="FechaControl">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="\d{1,8}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="DigitosControl">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="\d{1,2}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="ImporteCobro">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="\d{1,12}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="NIFCIFInteresado">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="9"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Gestor">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="6"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Datos">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="11"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Confirmacion">
<xs:complexType>
<xs:sequence>
<xs:element ref="Etiqueta"/>
<xs:element ref="Informacion"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Etiqueta">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="20"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Informacion">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Recibo">
<xs:complexType>
<xs:sequence>
<xs:element ref="AnioyTipoPres"/>
<xs:element ref="Concepto"/>
<xs:element ref="DatosRecibo"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="AnioyTipoPres">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="5"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Concepto">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="7"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="DatosRecibo">
<xs:complexType>
<xs:sequence>
<xs:element name="Linea1" type="linearecibo"/>
<xs:element name="Linea2" type="linearecibo"/>
<xs:element name="Linea3" type="linearecibo"/>
<xs:element name="Linea4" type="linearecibo"/>
<xs:element name="Linea5" type="linearecibo"/>
<xs:element name="Linea6" type="linearecibo"/>
<xs:element name="Linea7" type="linearecibo"/>
<xs:element name="Linea8" type="linearecibo"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="linearecibo">
<xs:restriction base="xs:string">
<xs:maxLength value="80"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="tipo_id">
<xs:restriction base="xs:string">
<xs:maxLength value="5"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="tipo_version">
<xs:restriction base="xs:string">
<xs:maxLength value="5"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

And if I change the import line at the MAIN XSD file from this:
<xs:import namespace="http://www.w3.org/2000/09/xmldsig#"/>
...to this
<xs:import namespace="http://www.w3.org/2000/09/xmldsig#
http://www.w3.org/TR/2002/REC-xmldsig-c ... schema.xsd"/>

then I get this another error message:

src-resolve.4.2: Error resolving component 'xmldsig:Signature'. It was detected that 'xmldsig:Signature' is in namespace 'http://www.w3.org/2000/09/xmldsig#', but components from this namespace are not referenceable from schema document 'file:///C:/Ivan/Programas/eclipse/workspace/TratamientoXML/xsd/PeticionPagosFirma.xsd'. If this is the incorrect namespace, perhaps the prefix of 'xmldsig:Signature' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:///C:/Ivan/Programas/eclipse/workspace/TratamientoXML/xsd/PeticionPagosFirma.xsd'.

It seems that the first error is because it does not find the Signature element, but when you provide it with the xsd then it said that it cannot be referenced from the MAIN XSD file.

Im using the last Xerces libraries and I just cannot get any idea to solve it.

Anyone can help me?

Thanks in advance.

Ivan Poza.

Radu
Posts: 6582
Joined: Fri Jul 09, 2004 5:18 pm

Some problems

Post by Radu » Thu Jun 30, 2005 11:37 am

Hi,

First of all the xml file should point to the main xsd schema like this:

Code: Select all

<PeticionFirmada xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="path/to/schema/main.xsd">
So the attribute xsi:noNamespaceSchemaLocation is added and points to the main schema.

Second of all the

Code: Select all

<xs:import namespace="http://www.w3.org/2000/09/xmldsig#
http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd"/>
you are using to import the signatures schema on the web should go to this:

Code: Select all

<xs:import namespace="http://www.w3.org/2000/09/xmldsig#"         schemaLocation="http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd"/>
So a schema location attribute is added to point to the shema on the web.

After that there will be errors reported in the XML file but only because it contains values which do not have the correct facets as described in the schema.

Hope this helps,
Regards, Radu.

ivanpgs
Posts: 3
Joined: Wed Jun 29, 2005 2:09 pm

Post by ivanpgs » Thu Jun 30, 2005 12:40 pm

Thanx for your answer but I am afraid that it does not the trick...

I do not why it stills does not recognize the schemaLocation or something like that, maybe it is a kind of bug regarding Xerces libraries...

The point is that even when I point to the schemaLocation It appears the same message (in red).

The others are just the errors having to do with facets and restrictions and those are allright.

An then the last in green are just messages relating the signature validation, which is okay too.

Thank you for your post and I will keep on searching a solution.

Error: URI=file:///C:/Ivan/Programas/eclipse/workspace/TratamientoXML/xsd/PeticionPagosFirma.xsd Line=15: src-resolve: Cannot resolve the name 'xmldsig:Signature' to a(n) 'element declaration' component.
Error: URI=null Line=5: cvc-length-valid: Value '50200203' with length = '8' is not facet-valid with respect to length '9' for type 'null'.
Error: URI=null Line=5: cvc-type.3.1.3: The value '50200203' of element 'NifAyuntamiento' is not valid.
Error: URI=null Line=14: cvc-maxLength-valid: Value '123456879' with length = '9' is not facet-valid with respect to maxLength '8' for type 'null'.
Error: URI=null Line=14: cvc-type.3.1.3: The value '123456879' of element 'NumeroSerieCertificado' is not valid.
Error: URI=null Line=18: cvc-length-valid: Value '1234568790' with length = '10' is not facet-valid with respect to length '4' for type 'null'.
Error: URI=null Line=18: cvc-type.3.1.3: The value '1234568790' of element 'Sucursal' is not valid.
Error: URI=null Line=25: cvc-minLength-valid: Value '12345' with length = '5' is not facet-valid with respect to minLength '9' for type 'null'.
Error: URI=null Line=25: cvc-type.3.1.3: The value '12345' of element 'Identificador' is not valid.
Error: URI=null Line=30: cvc-complex-type.2.4.a: Invalid content was found starting with element 'Confirmacion'. One of '{"":Gestor}' is expected.

30-jun-2005 11:54:38 org.apache.xml.security.utils.IdResolver getElementById
ADVERTENCIA: Found an Element using an insecure Id/ID/id search method: Peticion
30-jun-2005 11:54:38 org.apache.xml.security.signature.Reference verify
ADVERTENCIA: Verification failed for URI "#12345"

Radu
Posts: 6582
Joined: Fri Jul 09, 2004 5:18 pm

Post by Radu » Thu Jun 30, 2005 2:04 pm

Hi Ivan

The error you are receiving signifies that the signatures schema is not referred correctly in the import statement.
By the way, I notice that you are not using Oxygen for validation (the errors Oxygen gives for validation do not have the format that you are describing).
If you are running Oxygen as an Eclipse plugin maybe you should right click the XML file, go to Open With and choose Oxygen XML Editor.
Maybe the validator you are using cannot import remote schemas.
You could save the signatures schema on your disk in the same folder with the main schema file and refer to it locally in the <import> statement from the main schema like:

Code: Select all

<xs:import namespace="http://www.w3.org/2000/09/xmldsig#"         schemaLocation="xmldsig-core-schema.xsd"/>
Regards, Radu.

ivanpgs
Posts: 3
Joined: Wed Jun 29, 2005 2:09 pm

Post by ivanpgs » Thu Jun 30, 2005 2:25 pm

Yeah, I already did it too,

In fact, when I began it was a local file, just downloaded from the w3c web and put it in the hard-disk and treated as file:///path/to/schema/xmldsig-core-schema.xsd.
The same error is raised.

And you are rigth, I am not using Oxygen, I am only using Eclipse without the Oxygen plug-in. Maybe I should try Oxygen and try to see if the errors go away.

I'd try and tell you.

Thanks for your help.

Post Reply