towi
towi

Reputation: 22267

How to add a custom attribute to a XSD-1.1 validated XML Element

I want to add custom attributes to XML-elements in a validated document without changeing the original *.xsd. The XSD is version 1.1. I use python xmlschema library for validation.

The XML looks similar to this:

<?xml version="1.0" encoding="UTF-8"?>
<outer
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="root.xsd"
>

<inner custom:comment="do it now!" xmlns:custom="http://example.com/custom">
    <regular id="abc">Content</regular>
</inner>

</outer>

Currently the custom: element is rejected by xmlschema

Reason: '{http://example.com/custom}comment' attribute not allowed for element

Upvotes: 0

Views: 46

Answers (0)

Related Questions