Я использую этот шаблон:
<xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xpath-default-namespace="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:uuid="http://uuid.util.java"
exclude-result-prefixes="uuid">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="changeSet[createTable]">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="createTable"/>
<xsl:copy-of select="*[not(self::createTable)]"/>
</xsl:copy>
<xsl:if test="createTable/@remarks">
<xsl:element name="changeSet">
<xsl:attribute name="id" select="uuid:new-uuid()"/>
<xsl:attribute name="author">system</xsl:attribute>
<xsl:element name="setTableRemarks">
<xsl:copy-of select="createTable//(@tableName,@remarks)" />
</xsl:element>
<xsl:for-each select="createTable/column[@remarks]">
<xsl:element name="setColumnRemarks">
<xsl:copy-of select="../@tableName" />
<xsl:attribute name="columnName" select="@name"/>
<xsl:copy-of select="@remarks"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:if>
</xsl:template>
<xsl:template match="createTable/@remarks"/>
<xsl:template match="createTable/column/@remarks"/>
</xsl:transform>
для преобразования xml следующим образом:
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" 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.6.xsd">
<changeSet author="system (generated)" id="1538720867962-1">
<createTable remarks="Journal event detail attribute mapping" tableName="AS_JOURNALEVENTDETAILATTRMAP">
<column name="JOURNALEVENTTYPEID" remarks="Journal event type identifier" type="NUMBER(9, 0)">
<constraints primaryKey="true" primaryKeyName="PK$AS_JOURNALEVENTDETATTRMAP"/>
</column>
<column name="JOURNALEVENTDETAILATTRID" remarks="Journal event detail attribute identifier" type="NUMBER(9, 0)">
<constraints primaryKey="true" primaryKeyName="PK$AS_JOURNALEVENTDETATTRMAP"/>
</column>
<column name="LISTORDER" remarks="Order in list" type="NUMBER(9, 0)">
<constraints nullable="false"/>
</column>
</createTable>
</changeSet>
</databaseChangeLog>
Я ожидаю, что результат будет:
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
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.6.xsd">
<changeSet author="system (generated)" id="1538720867962-1">
<createTable tableName="AS_JOURNALEVENTDETAILATTRMAP">
<column name="JOURNALEVENTTYPEID" type="NUMBER(9, 0)">
<constraints primaryKey="true" primaryKeyName="PK$AS_JOURNALEVENTDETATTRMAP"/>
</column>
<column name="JOURNALEVENTDETAILATTRID" type="NUMBER(9, 0)">
<constraints primaryKey="true" primaryKeyName="PK$AS_JOURNALEVENTDETATTRMAP"/>
</column>
<column name="LISTORDER" type="NUMBER(9, 0)">
<constraints nullable="false"/>
</column>
</createTable>
</changeSet>
<changeSet id="c85f187d-f917-4948-8c48-7b1a132dd79e" author="system">
<setTableRemarks remarks="Journal event detail attribute mapping" tableName="AS_JOURNALEVENTDETAILATTRMAP"/>
<setColumnRemarks tableName="AS_JOURNALEVENTDETAILATTRMAP"
columnName="JOURNALEVENTTYPEID"
remarks="Journal event type identifier"/>
<setColumnRemarks tableName="AS_JOURNALEVENTDETAILATTRMAP"
columnName="JOURNALEVENTDETAILATTRID"
remarks="Journal event detail attribute identifier"/>
<setColumnRemarks tableName="AS_JOURNALEVENTDETAILATTRMAP"
columnName="LISTORDER"
remarks="Order in list"/>
</changeSet>
</databaseChangeLog>
но вместо этого я получаю следующее:
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
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.6.xsd">
<changeSet author="system (generated)" id="1538720867962-1">
<createTable tableName="AS_JOURNALEVENTDETAILATTRMAP">
<column name="JOURNALEVENTTYPEID" type="NUMBER(9, 0)">
<constraints primaryKey="true" primaryKeyName="PK$AS_JOURNALEVENTDETATTRMAP"/>
</column>
<column name="JOURNALEVENTDETAILATTRID" type="NUMBER(9, 0)">
<constraints primaryKey="true" primaryKeyName="PK$AS_JOURNALEVENTDETATTRMAP"/>
</column>
<column name="LISTORDER" type="NUMBER(9, 0)">
<constraints nullable="false"/>
</column>
</createTable>
</changeSet>
<changeSet id="c85f187d-f917-4948-8c48-7b1a132dd79e" author="system">
<setTableRemarks remarks="Order in list" tableName="AS_JOURNALEVENTDETAILATTRMAP"/>
<setColumnRemarks tableName="AS_JOURNALEVENTDETAILATTRMAP"
columnName="JOURNALEVENTTYPEID"
remarks="Journal event type identifier"/>
<setColumnRemarks tableName="AS_JOURNALEVENTDETAILATTRMAP"
columnName="JOURNALEVENTDETAILATTRID"
remarks="Journal event detail attribute identifier"/>
<setColumnRemarks tableName="AS_JOURNALEVENTDETAILATTRMAP"
columnName="LISTORDER"
remarks="Order in list"/>
</changeSet>
</databaseChangeLog>
примечание: проблема в элементе setTableRemarks и атрибуте remarks.Он скопирован с другого элемента, а не с createTable, как мне кажется, так и должно быть.Что-то не так в моем шаблоне или есть другая проблема?
Саксонская библиотека, используемая для этого, является 9.8.0-14
Я также пытался с 9.9.0-1
, но ничего не изменилось.