derive from foreign xml schema



This is an xml example I want to be able to validate with my selfmade schema. The whole EncryptedData part is actually syntax of the XML Encryption specification.



<?xml version="1.0" encoding="UTF-8"?>
<Foo xmlns="http://www.foo.org/FOO">
<EncryptedData>
<EncryptionMethod
Algorithm="http://ift.tt/1cxljQC" />
<ds:KeyInfo xmlns:ds="http://ift.tt/uq6naF">
<ds:KeyName>John Smith</ds:KeyName>
</ds:KeyInfo>
<CipherData>
<CipherValue>DEADBEEF</CipherValue>
</CipherData>
</EncryptedData>
</Foo>


So I tried deriving from XML Encryption and came up with this:



<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
xmlns:xsd="http://ift.tt/tphNwY"
xmlns:xenc='http://ift.tt/rAMjm9'
xmlns:xenc11="http://ift.tt/1uFgHSc"
xmlns:foo="http://www.foo.org/Foo"
targetNamespace="http://www.foo.org/Foo">
<xsd:import namespace='http://ift.tt/rAMjm9' />
<xsd:import namespace='http://ift.tt/1uFgHSc' />
<xsd:element name="Foo">
<xsd:complexType>
<xsd:choice>
<xsd:element name="myItem" minOccurs="1" maxOccurs="unbounded" type="anyType"/>
<xsd:element ref="xenc:EncryptedData" minOccurs="1"
maxOccurs="unbounded" />
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>


But then my actual xml would have to look like this. I need to prefix all the XML Encryption elements with namespaces as I imported them.



<?xml version="1.0" encoding="UTF-8"?>
<foo
xmlns="http://www.foo.org/Foo"
xmlns:xenc='http://ift.tt/rAMjm9'/>
<xenc:EncryptedData>
<xenc:EncryptionMethod
Algorithm="http://ift.tt/1cxljQC" />
<ds:KeyInfo xmlns:ds="http://ift.tt/uq6naF">
<ds:KeyName>John Smith</ds:KeyName>
</ds:KeyInfo>
<xenc:CipherData>
<xenc:CipherValue>DEADBEEF</xenc:CipherValue>
</xenc:CipherData>
</xenc:EncryptedData>
</foo>


But I also fail to actually change the import into an include as target namespaces differ. (my own being different from the one defined in the xml encryption schema) Is there a way to do this so you can even use it without the namespaces? Or will it only work with prefixes?


No comments:

Post a Comment