Stefan (archive)
Usenet Archive
- Joined
- Jan 3, 2001
- Messages
- 114
- Reaction score
- 0
Hello,
I'm trying to write a XML Schema to validate against a XML file which holds an element which contains either a plaint text password or a XML encryption element. A plain text example is:
<Password>mySecret</Password>
or a XML encrypted element:
<Password>
<EncryptedData xmlns="http://www.w3.org/2001/04/xmlenc#" Type="http://www.w3.org/2001/04/xmlenc#Content"> <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/> <CipherData> <CipherValue>Jha8fYGDje49Tkz0=</CipherValue> </CipherData> </EncryptedData> </Password>
I tried to validate against it with following XML Schema:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" elementFormDefault="qualified">
<xsd:import namespace="http://www.w3.org/2001/04/xmlenc#"
schemaLocation="http://www.w3.org/TR/2002/REC-xmlenc-core-20021210/xenc-schema.xsd"/>
<xsd:element name="Secret">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="EncryptedData" type="xenc:EncryptedDataType" minOccurs="0" maxOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element>
But it fails with an error message like this:
element EncryptedData: Schemas validity error : Element '{http://www.w3.org/2001/04/xmlenc#}EncryptedData': This element is not expected. Expected is ( EncryptedData ).
I don't know why the EncryptedData-Node isn't in the namespace of xmlenc.
The problem is that the schema must support two types of <Password>. One time it could be a pure xsd:string and the other one could be a parent of EncryptedData.
Any ideas how to solve that?
Best regards
Stefan
I'm trying to write a XML Schema to validate against a XML file which holds an element which contains either a plaint text password or a XML encryption element. A plain text example is:
<Password>mySecret</Password>
or a XML encrypted element:
<Password>
<EncryptedData xmlns="http://www.w3.org/2001/04/xmlenc#" Type="http://www.w3.org/2001/04/xmlenc#Content"> <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/> <CipherData> <CipherValue>Jha8fYGDje49Tkz0=</CipherValue> </CipherData> </EncryptedData> </Password>
I tried to validate against it with following XML Schema:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" elementFormDefault="qualified">
<xsd:import namespace="http://www.w3.org/2001/04/xmlenc#"
schemaLocation="http://www.w3.org/TR/2002/REC-xmlenc-core-20021210/xenc-schema.xsd"/>
<xsd:element name="Secret">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="EncryptedData" type="xenc:EncryptedDataType" minOccurs="0" maxOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element>
But it fails with an error message like this:
element EncryptedData: Schemas validity error : Element '{http://www.w3.org/2001/04/xmlenc#}EncryptedData': This element is not expected. Expected is ( EncryptedData ).
I don't know why the EncryptedData-Node isn't in the namespace of xmlenc.
The problem is that the schema must support two types of <Password>. One time it could be a pure xsd:string and the other one could be a parent of EncryptedData.
Any ideas how to solve that?
Best regards
Stefan