I need to remove "tei:" from each tag. My original xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<?oxygenRNGSchema="http://www.teic.org/release/xml/tei/custom/schema/relaxng/tei_all.rn"type="xml"?>
<?xml-stylesheet type="text/xsl" href="jerome-html-proof.xsl"?>
<TEI
xmlns="http://www.tei-c.org/ns/1.0"
xmlns:tei="http://www.tei-c.org/ns/1.0">
<teiHeader>
<fileDesc>
<titleStmt>
<title>Chronicles (Latin working edition, based on Helm)</title>
<author>Jerome</author>
</titleStmt>
<publicationStmt>
<p>Unpublished</p>
</publicationStmt>
<sourceDesc>
<p>PD online text from http://www.tertullian.org/fathers/index.htm#jeromechronicle, entitled
"Jerome, Chronicle (2005)" and based on pages of Helm's edition indicated in milestone
elements. </p>
<p>Source page includes note, "This text was transcribed by JMB. All material on this page
is in the public domain - copy freely." </p>
</sourceDesc>
</fileDesc>
</teiHeader>
<text>
<body>
<div
n="preface"
type="prefatory"> </div>
<table>
<row role="header">
<cell ana="abraham"/>
<cell ana="assyrians">Regnum Assyriorum</cell>
<cell ana="sacred-history"/>
<cell ana="hebrews"> Hebraeorum gentis exordium</cell>
<cell ana="sicyonians"> Regnum Sicyoniorum</cell>
<cell ana="gentile-history"/>
<cell ana="egyptians"> Regnum Aegyptiorum</cell>
<cell ana="adbc"> BC</cell>
</row>
<row role="regnal">
<cell/>
<cell/>
<cell/>
<cell/>
<cell>Sicyoniorum III, TELCHIN, annis XX.</cell>
</row>
<row>
<cell/>
<cell>15</cell>
<cell/>
<cell>25</cell>
<cell>1</cell>
<cell/>
<cell>25</cell>
<cell>1992</cell>
</row>
</table>
</body>
</text>
</TEI>
When I run my script, I get the same output but with "tei:" in each tag:
<tei:TEI>
<tei:text>
<tei:body>
<tei:div>
<tei:row role="header">...........
I'm trying to add a value to each row that is not used as a header and does not mark a change in ruler. My code is:
import groovy.xml.StreamingMarkupBuilder
import groovy.xml.XmlUtil
def TEI = new XmlSlurper().parse(new File('file.xml'))
def jeromeRow = new File("file-row.xml")
def x = 0
for (row in TEI.text.body.div.table.row) {
if (row.@role != 'regnal' && row.@role != 'header'){
x = x + 1
row.@n = 'r' + x
}
}
def outputBuilder = new StreamingMarkupBuilder()
String result = outputBuilder.bind{ mkp.yield TEI }
jeromeRow << XmlUtil.serialize(result)
How do I prevent my script from making this unwanted change to my xml file.
Your code looks correct except for the non existing 'table'. When I run the following in groovyConsole, it looks just fine:
Looking at your code again, I see that you at the end APPEND data to the end of the file.
Could it be that you for some reason (in code not submitted) are appending empty data into an already incorrect file?