I am trying to create my own extension for Liquibase. The changeLog looks something like this:
The corresponding XSD looks like this:
Then I have a Change implementation that contains the following getters and setters:
The class Attribute extends AbstractLiquibaseSerializable and contains a bunch of getters and setters and returns the same namespace value in getSerializedObjectNamespace()
Liquibase parses my changeLog and processes my createFoo tag, but it never calls setAttributes() or addAttribute() so my Change is not populated completely.
I debugged the load() method of my Change implementation and the ParsedNode instance that is passed to it, does not contain an "attributes" child nor any "attribute" children. I also tried a XSD version where the intermediate <attributes> was removed, but that didn't work either?
XMLChangeLogSAXHandler.startElement() is never called for the nested tags, only for my createFoo tag.
I suspect that this has something to do with XML namespaces, but I'm unsure what exactly. My CreateFoo class implements
What am I missing?
- <databaseChangeLog
- xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
- xmlns:my-ext="http://www.liquibase.org/xml/ns/my-ext"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd
- http://www.liquibase.org/xml/ns/my-ext my-ext.xsd">
- <changeSet author="tkellerer" id="1">
- <my-ext:createFoo name="Bar">
- <my-ext:attributes>
- <my-ext:attribute name="a1" dataType="integer"/>
- <my-ext:attribute name="a2" dataType="integer"/>
- </my-ext:attributes>
- </my-ext:createFoo>
- </changeSet>
- </databaseChangeLog>
The corresponding XSD looks like this:
- <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- targetNamespace="http://www.liquibase.org/xml/ns/my-ext"
- xmlns="http://www.liquibase.org/xml/ns/my-ext"
- elementFormDefault="qualified">
- <xsd:element name="createFoo">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="attributes" minOccurs="0" maxOccurs="1">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="attribute" minOccurs="1" maxOccurs="unbounded">
- <xsd:complexType>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="dataType" type="xsd:string" use="required"/>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
- </xsd:element>
- </xsd:schema>
Then I have a Change implementation that contains the following getters and setters:
- @DatabaseChange(name = "createFoo", priority = ChangeMetaData.PRIORITY_DEFAULT)
- public class CreateFoo
- extends AbstractChange {
- ....
- public void addAttribute(Attribute attr) {
- attributes.add(attr);
- }
- @DatabaseChangeProperty
- public List<Attribute> getAttributes() {
- return attributes;
- }
- public void setAttributes(List<Attribute> attributeList) {
- logger.info("Attributes set: " + attributeList);
- this.attributes.clear();
- if (attributeList != null) {
- this.attributes.addAll(attributeList);
- }
- }
- @Override
- public String getSerializableFieldNamespace(String field) {
- return "http://www.liquibase.org/xml/ns/my-ext";
- }
- @Override
- public String getSerializedObjectNamespace() {
- return "http://www.liquibase.org/xml/ns/my-ext";
- }
- ....
- }
The class Attribute extends AbstractLiquibaseSerializable and contains a bunch of getters and setters and returns the same namespace value in getSerializedObjectNamespace()
Liquibase parses my changeLog and processes my createFoo tag, but it never calls setAttributes() or addAttribute() so my Change is not populated completely.
I debugged the load() method of my Change implementation and the ParsedNode instance that is passed to it, does not contain an "attributes" child nor any "attribute" children. I also tried a XSD version where the intermediate <attributes> was removed, but that didn't work either?
XMLChangeLogSAXHandler.startElement() is never called for the nested tags, only for my createFoo tag.
I suspect that this has something to do with XML namespaces, but I'm unsure what exactly. My CreateFoo class implements
What am I missing?