I'm willing to use XSLT
to transform XML files to other XML files by removing (TextLine
) elements. However, the elements are not removed as I expect in the output XML files. I imagine that I'll have to modify the XSLT file, but I don't know how. Let me know what should be done.
I suspect that the root cause of the issue is that elements in the XML files have an empty prefix namespace.
The details are the following ones.
An XML test-01.xml
file that contains empty prefix namespace elements:
<?xml version="1.0" encoding="UTF-8"?>
<alto xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.loc.gov/standards/alto/ns-v4#"
xsi:schemaLocation="http://www.loc.gov/standards/alto/ns-v4# http://www.loc.gov/standards/alto/v4/alto-4-2.xsd">
<TextLine TAGREFS="LT9"/>
<TextLine TAGREFS="LT10"/>
<TextLine TAGREFS="LT9"/>
<TextLine TAGREFS="LT8"/>
</alto>
And I'm using the following date.xslt
file:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="TextLine"/>
</xsl:stylesheet>
Note: I'm using python lxml
to perform the transformation. However, this shouldn't have any influence on the process as I could use any other XML transformer as xsltproc
.