<p>I am creating a WordML document from an xml file whose elements sometimes contain html-formatted text.  </p>

<pre><code>&lt;w:p&gt;
  &lt;w:r&gt;
    &lt;w:t&gt; html formatted content is in here taken from xml file! &lt;/w:t&gt;
  &lt;/w:r&gt;
&lt;/w:p&gt;
</code></pre>

<p>This is how my templates are sort of set up.  I have a recursive call-template function that does text replacement against the source xml content.  When it comes across a "<code>&lt;b&gt;</code>" tag, I output a string in CDATA containing "<code>&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:rPr&gt;&lt;w:b/&gt;&lt;/w:rPr&gt;&lt;w:t&gt;</code>" to close the current run and start up a new run with bold formatting enabled.  when it gets to a "<code>&lt;/b&gt;</code>" tag, it replaces it with the following CDATA string "<code>&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;</code>".</p>

<p>What I'd like to do is use XSL to close the run tag and start a new run without using CDATA string inserts.  Is this possible?</p>

I can most probably help you if only I understood your problem... Is the html in a CDATA section or is it parsed as part of the input doc (and thus well-formed XML)?
Since you talk about 'text replacement' I'll assume that you treat the 'html formatted content' as a single string (CDATA) and therefor need a recursive call-template function to perform string replacement. The only way you're going to be able to use an XSL matching template to do what you're doing now is to make the html part of the parsed document (your input document). In such a case you could just match the
```
b
```
tag and replace it with the appropriate output (again: this assumes that it can always be parsed as valid XML). Your problem now has shifted... since (if I understood your problem correctly) what you're trying to do is close the
```
w:t
```
and
```
w:r
```
elements and then 'reopen' them... this is hard because it's (as you probably suspect) very hard to do this nicely in XSLT (you cannot just create an element in template A and then close it in template B). You'll have to start messing with unescaped output etc. to make this happen. I now I've made a lot of assumptions but here is a small example to help you on your way:
input.xml
```
```
<doc xmlns:w="urn:schemas-microsoft-com:office:word">
<w:p>
  <w:r>
    <w:t>before<b>bold</b>after</w:t>
  </w:r>
</w:p>
</doc>
```
```
convert_html.xsl
```
```
<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="/doc/w:p/w:r/w:t//b">
  <xsl:value-of select="'&lt;/w:t>&lt;/w:r>&lt;w:r>&lt;w:rPr>&lt;w:b/>&lt;/w:rPr>&lt;w:t>'" disable-output-escaping="yes" />
  <xsl:apply-templates select="@*|node()"/>
  <xsl:value-of select="'&lt;/w:t>&lt;/w:r>&lt;w:r>&lt;w:t>'" disable-output-escaping="yes" />
</xsl:template>
```
```
Now running
```
```
xalan input.xml convert_html.xsl
```
```
produces
```
```
<?xml version="1.0" encoding="UTF-8"?><doc xmlns:w="urn:schemas-microsoft-com:office:word">
<w:p>
  <w:r>
    <w:t>before</w:t></w:r><w:r><w:rPr><w:b/></w:rPr><w:t>bold</w:t></w:r><w:r><w:t>after</w:t>
  </w:r>
</w:p>
</doc>
```
```
which I guess is what you wanted.
Hope this helps you somewhat.