Замена строк в различных файлах XML

Приведен следующий xml-файл со знанием того, что структура и содержимое могут измениться:

<something>
  <parent>
    <child>Bird is the word 1.</child>
    <child>Curd is the word 2.</child>
    <child>Nerd is the word 3.</child>
  </parent>
  <parent>
    <child>Bird is the word 4.</child>
    <child>Word is the word 5.</child>
    <child>Bird is the word 6.</child>
  </parent>
</something>

Я хотел бы использовать способ xquery (и даже xslt), чтобы заменить все экземпляры предоставленной строки другим. Например, заменить слово «Птица» на «Собака». Поэтому результаты будут:

<something>
  <parent>
    <child>Dog is the word 1.</child>
    <child>Curd is the word 2.</child>
    <child>Nerd is the word 3.</child>
  </parent>
  <parent>
    <child>Dog is the word 4.</child>
    <child>Word is the word 5.</child>
    <child>Dog is the word 6.</child>
  </parent>
</something>

Я понятия не имею, возможно ли это вообще. Каждая попытка, которую я сделал, удаляла теги Я даже попробовал этот пример (http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx), но это для текста, а не для всего документа.

Пожалуйста помоги!

ОБНОВИТЬ

Я попытался запустить с предложением xslt 2.0, так как оно казалось лучшим. Пытаясь изменить это для моего случая, я продолжаю выдыхаться.

Я хочу передать параметр XML, чтобы определить замены. Итак, изменив xslt следующим образом:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output indent="yes"/>
  <xsl:strip-space elements="*"/>
  <xsl:param name="list">
<words>
  <word>
        <search>Bird</search>
    <replace>Dog</replace>
  </word>
      <word>
        <search>word</search>
    <replace>man</replace>
  </word>
</words>
  </xsl:param>


<xsl:template match="@*|*|comment()|processing-instruction()">
  <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="text()">
  <xsl:param name="chosen" select="." />
<xsl:for-each select="$list//word">
  <xsl:variable name="search"><xsl:value-of select="search" /></xsl:variable>
  <xsl:analyze-string select="$chosen" regex="{$search}">
    <xsl:matching-substring><xsl:value-of select="replace" /></xsl:matching-substring>
    <xsl:non-matching-substring><xsl:value-of select="$chosen"/></xsl:non-matching-substring>
  </xsl:analyze-string>
</xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

Результаты:

<something>
  <parent>
    <child>Bird is the word 1.Bird is the word 1.</child>
    <child>Curd is the word 2.Curd is the word 2.</child>
    <child>Nerd is the word 3.Nerd is the word 3.</child>
  </parent>
  <parent>
    <child>Bird is the word 4.Bird is the word 4.</child>
    <child>Word is the word 5.Word is the word 5.</child>
    <child>Bird is the word 6.Bird is the word 6.</child>
  </parent>
</something>

Само собой разумеется, но я не хочу, чтобы это дублировалось и также неправильно.

Пожалуйста помоги!

Ответы на вопрос(4)

Ваш ответ на вопрос