У меня есть набор xml-файлов в папке и вложенных папках, которые мне нужно немного изменить, изменив заголовок темы из UPPER CASE в Title Case.XSLT преобразует набор XML-файлов в папку и несколько подпапок
После изменение этого: ПЕРВЫЙ ПАРАГРАФ МОЕГО ИЗДАНИЯ должно выглядеть следующим образом: первый абзац моей публикации
Структура папки выглядит следующим образом Docs/документы/folder1, Docs/документы/folder2, Docs/documents/folder3 и т. д.
Я хотел бы использовать XSLT в сочетании с скриптом Ant или любым другим подходом для выполнения изменений. Перезапись исходных файлов в порядке, потому что мне нужно сохранить ту же структуру папок.
Этот подход XSLT: Transform XML files tree является самым близким к тому, чего я пытаюсь достичь, но я не в состоянии.
файлы XML источник выглядеть следующим образом:
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/" audience="(12-7-1)"
id="parag128" ditaarch:DITAArchVersion="1.0"
domains="(topic ui-d) (topic hi-d) (topic pr-d) (topic sw-d) (topic ut-d)"
class="- topic/topic ">
<title class="- topic/title ">FIRST PARAGRAPH OF MY PUBLICATION</title>
<body class="- topic/body ">
<p class="- topic/p ">The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
</p>
</body>
</topic>
И полученный XML должен быть как ниже:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/" audience="(12-7-1)"
id="parag128" ditaarch:DITAArchVersion="1.0"
domains="(topic ui-d) (topic hi-d) (topic pr-d) (topic sw-d) (topic ut-d)"
class="- topic/topic ">
<title class="- topic/title ">First Paragraph Of My Publication</title>
<body class="- topic/body ">
<p class="- topic/p ">The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
</p>
</body>
</topic>
Я это XSLT
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:param name="files" select="collection('../../*.dita;recurse=yes')"/>
<xsl:template match="topic/title/text()">
<xsl:analyze-string select="." regex="\p{{L}}+">
<xsl:matching-substring>
<xsl:value-of select="concat(upper-case(substring(.,1,1)), lower-case(substring(.,2)))"/>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>
от этого вопроса Converting to text to lowercase in nodes and child nodes in xsl, но я не могу заставить его работать с несколькими файлами.
Благодарим за помощь.
Какая версия XSLT? –
XSLT 2.0 с Saxon-EE 9.5.1.2 – ManUO