将xml文件转换为纯文本格式

时间:2012-12-12 21:22:23

标签: xslt

我有一个xml文件,我想将其翻译成纯文本文件。

<?xml version="1.0" encoding="UTF-8"?>
<abc xmlns="ddn:cns-org:v5">
    <section>
        <title>PREORDER</title>
        <code code="0" cs="12.222" csn="CSN" />
        <text>
            <paragraph>
                <content>preorder.</content>
                <content></content>
            </paragraph>
            <paragraph>
                <content>preorder description.</content>
                <content>preorder detail goes here.</content>
            </paragraph>
        </text>
    </section>
    <section>
        <title>POSTORDER</title>
        <code code="0" cs="12.222" csn="CSN" />
        <text>
            <paragraph>
                <content>postorder.</content>
            </paragraph>
        </text>
    </section>
</abc>

我希望输出如下:

PREORDER
(ignore the line of <code .../>
pre-order.
(Note: if there is no content - <content></content>, don't record anything)
preorder description.
preorder detail goes here.

POSTORDER
post-order.

我试图使用xsl转换,但我真的不了解路径/节点。我有类似下面的东西,显然它没有用。请帮忙。

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    abc xmlns="ddn:cns-org:v5">
    <xsl:output method="text" omit-xml-declaration="yes"/>

    <!-- ***********************************************************
        Call template process section 
         ************************************************************-->
    <xsl:template match="/">
      <!--  <xsl:for-each select="abc"> -->
       <xsl:for-each select="section">
            <xsl:call-template name="process_section"> </xsl:call-template>
       </xsl:for-each>
      <!--  </xsl:for-each> -->
    </xsl:template>


     <xsl:template name="process_section">
        <!-- Choose : Section or Subsection  -->
        <xsl:choose>

            <!-- ***********************************************************************************
                (if section: 
                *check if not empty title  
                * Bring to upper case
                * check if already one colon, don't put any more
                * put newline 
            ******************************************************************************************-->
            <xsl:when test=" local-name(.)='abc' ">
                <xsl:if test="not(string-length(normalize-space(./section/title))=0)">
                    <xsl:variable name="title" select="string(./section/title)"/>
                    <xsl:value-of
                        select="translate($title, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
                    <xsl:if test="not( substring($title, string-length($title),1)=':' )">
                        <xsl:text>:</xsl:text>
                    </xsl:if>
                    <xsl:text>&#xa;</xsl:text>
                </xsl:if>
            </xsl:when>

            ...

谢谢,戴夫


现在我需要将xml文件转换为格式良好的文本文件。将源xml文件指定为:

  <?xml version="1.0" encoding="UTF-8"?>
    <abc xmlns="ddn:cns-org:v5">
        <section>
            <title>PREOPERATIVE DIAGNOSIS  </title>
            <code code="0" cs="12.222" csn="CSN" />
            <text>
                <paragraph>
                    <content>__ c</content>
                    <content>ataract.</content>
                </paragraph>
            </text>
        </section>
        <section>
            <title>POSTOPERATIVE DIAGNOSIS</title>
            <code code="0" cs="12.222" csn="CSN" />
            <text>
                <paragraph>
                    <content>__ c</content>
                    <content>ataract.</content>
                </paragraph>
            </text>
        </section>
        <section>
            <title>OPERATION</title>
            <code code="0" cs="12.222" csn="CSN" />
            <text>
                <paragraph>
                    <content>Pars plana vitrectomy
                        and epiretinal membrane removal. Phacoemulsification with posterior
                        chamber lens implant __(Control #</content>
                    <content>__</content>
                    <content>) </content>
                </paragraph>
            </text>
        </section>
        <section>
            <title>SURGEON</title>
            <code code="0" cs="12.222" csn="CSN" />
            <text>
                <paragraph>
                    <content>Dr. J. R. xxx
                    </content>
                </paragraph>
            </text>
        </section>
        <section>
            <title>DOCTORS IN ATTENDANCE</title>
            <code code="0" cs="12.222" csn="CSN" />
            <text>
                <paragraph />
            </text>
        </section>
        <section>
            <title>ANESTHETIST</title>
            <code code="0" cs="12.222" csn="CSN" />
            <text>
                <paragraph />
            </text>
        </section>
        <section>
            <title>ANESTHESIA</title>
            <code code="0" cs="12.222" csn="CSN" />
            <text>
                <paragraph />
            </text>
        </section>
        <section>
            <title>CLINICAL NOTE</title>
            <code code="0" cs="12.222" csn="CSN" />
            <text>
                <paragraph />
            </text>
        </section>
        <section>
            <title>OPERATIVE PROCEDURE</title>
            <code code="0" cs="12.222" csn="CSN" />
            <text>
                <paragraph>
                    <content>Topical sterilization,
                        anesthesia and dilatation were carried out in the Day Surgery Unit
                        before the patient was brought to the Operating room. </content>
                </paragraph>
                <paragraph />
                <paragraph>
                    <content>The patient was
                        prepared with Proviodine. The patient was then draped. Special
                        attention was directed to the eyelids/lashes, prepping and draping.
                        A speculum was inserted into the fornices of the</content>
                    <content> __</content>
                    <content> eye. Subconjunctival
                        Xylocaine was given. A small conjunctival peritomy was made in the
                        area of the subconjunctival injection. Three cc of 2% Xylocaine and
                        0.75% Marcaine were injected into the sub-Tenon's space through the
                        peritomy.  </content>
                </paragraph>
                <paragraph />
                <paragraph>
                    <content>A paracentesis was
                        performed superiorly and inferiorly. Intraocular nonpreserved
                        Xylocaine was used. A viscoelastic was injected into the anterior
                        chamber. The eye was entered with a 3 mm keratome. The anterior
                        capsulectomy was done under a viscoelastic. Hydrodissection and
                        delineation of the nucleus was carried out. The
                        phaco-emulsification was initiated. The phacoemulsification time
                        was </content>
                    <content>__</content>
                    <content> seconds. At the
                        completion of the phacoemulsification, the cortical material was
                        irrigated and aspirated from the eye. The posterior capsule was
                        polished. The intraocular lens was inserted under a viscoelastic.
                        The intraocular lens power was __ diopters.   </content>
                </paragraph>
                <paragraph />
                <paragraph>
                    <content>The lens was the dialed
                        into position with the lens pick. Irrigation and aspiration of the
                        viscoelastic was then carried out. The wound was tested to ensure
                        that there was no wound leak.  </content>
                </paragraph>
                <paragraph />
                <paragraph>
                    <content>Additional periglobal
                        anesthesia of 2% Xylocaine and 0.75% Marcaine was injected into the
                        sub-Tenon's space through the peritomy. </content>
                </paragraph>
                <paragraph />
                <paragraph>
                    <content>The 25-gauge cannulas
                        were then placed inferotemporal, supratemporal and supranasally. In
                        the infratemporal cannula an infusion placed.  </content>
                </paragraph>
                <paragraph />
                <paragraph>
                    <content>A vitrectomy was then
                        carried out.  </content>
                </paragraph>
                <paragraph />
                <paragraph>
                    <content>__ (Dr. xxx will
                        refer to this area as an "open paragraph</content>
                    <content>"</content>
                    <content>- DELETE THIS
                        INFORMATION</content>
                    <content>)</content>
                </paragraph>
                <paragraph />
                <paragraph>
                    <content>At the completion of
                        the vitrectomy, the peripheral retina was reinspected to ensure
                        there was no untreated peripheral retinal tears or detachment. The
                        cannulas were removed. The scleral wounds inspected and if a wound
                        leak was identified, then this was closed with 9-0 Vicryl suture.
                        Otherwise interrupted 9-0 Vicryl sutures were placed.
                        Subconjunctival Decadron and cefuroxime were given.  </content>
                </paragraph>
                <paragraph />
                <paragraph>
                    <content>A patch and shield
                        applied.    </content>
                </paragraph>
                <paragraph />
                <paragraph>
                    <content>The patient left the
                        Operating Room in satisfactory condition.  </content>
                </paragraph>
            </text>
        </section>
        <section>
            <title>ADDENDUM</title>
            <code code="0" cs="12.222" csn="CSN" />
            <text>
                <paragraph />
            </text>
        </section>
        <section>
            <title>POSTOPERATIVE TOPICAL EYE DROPS</title>
            <code code="0" cs="12.222" csn="CSN" />
            <text>
                <paragraph>
                    <content>1. Maxidex.</content>
                </paragraph>
                <paragraph>
                    <content>2. Nevanac.</content>
                </paragraph>
                <paragraph>
                    <content>3. Vigamox.</content>
                </paragraph>
            </text>
        </section>
        <section>
            <title>POSTOPERATIVE FOLLOWUP</title>
            <code code="0" cs="12.222" csn="CSN" />
            <text>
                <paragraph>
                    <content>__</content>
                </paragraph>
            </text>
        </section>
    </abc>

我希望得到如下输出。

PREOPERATIVE DIAGNOSIS:

__ cataract.

POSTOPERATIVE DIAGNOSIS:

__ cataract.

OPERATION:

Pars plana vitrectomy and epiretinal membrane removal.  Phacoemulsification with posterior chamber lens implant __(Control #__) 

SURGEON:

Dr. J. R. xxx 

DOCTORS IN ATTENDANCE:

ANESTHETIST:

ANESTHESIA:

CLINICAL NOTE:

OPERATIVE PROCEDURE:

Topical sterilization, anesthesia and dilatation were carried out in the Day Surgery Unit before the patient was brought to the Operating room. 

The patient was prepared with Proviodine.  The patient was then draped. Special attention was directed to the eyelids/lashes, prepping and draping.   A speculum was inserted into the fornices of the __ eye.  Subconjunctival Xylocaine was given.  A small conjunctival peritomy was made in the area of the subconjunctival injection.  Three cc of 2% Xylocaine and 0.75% Marcaine were injected into the sub-Tenon's space through the peritomy.  

A paracentesis was performed superiorly and inferiorly. Intraocular nonpreserved Xylocaine was used. A viscoelastic was injected into the anterior chamber.  The eye was entered with a 3 mm keratome.  The anterior capsulectomy was done under a viscoelastic. Hydrodissection and delineation of the nucleus was carried out.  The phaco-emulsification was initiated.  The phacoemulsification time was __ seconds.  At the completion of the phacoemulsification, the cortical material was irrigated and aspirated from the eye.  The posterior capsule was polished.  The intraocular lens was inserted under a viscoelastic.  The intraocular lens power was __  diopters.   

The lens was the dialed into position with the lens pick.  Irrigation and aspiration of the viscoelastic was then carried out.  The wound was tested to ensure that there was no wound leak.  

Additional periglobal anesthesia of 2% Xylocaine and 0.75% Marcaine was injected into the sub-Tenon's space through the peritomy. 

The 25-gauge cannulas were then placed inferotemporal, supratemporal and supranasally.  In the infratemporal cannula an infusion placed.  

A vitrectomy was then carried out.  

__ (Dr. xxx will refer to this area as an "open paragraph"- DELETE THIS INFORMATION)

At the completion of the vitrectomy, the peripheral retina was reinspected to ensure there was no untreated peripheral retinal tears or detachment.  The cannulas were removed.  The scleral wounds inspected and if a wound leak was identified, then this was closed with 9-0 Vicryl suture.   Otherwise interrupted 9-0 Vicryl sutures were placed.  Subconjunctival Decadron and cefuroxime were given.  

A patch and shield applied.    

The patient left the Operating Room in satisfactory condition.  

ADDENDUM:

POSTOPERATIVE TOPICAL EYE DROPS:

1.  Maxidex.
2.  Nevanac.
3.  Vigamox.

POSTOPERATIVE FOLLOWUP:
__

转换规则是:

应使用新的空白行分隔各个部分。

部分标题应为全部大写字母,后跟冒号(:)并应进行修剪。

每个标题应该用新的空行分隔(在它之前和之后)。

每个段落应该用新的空行分隔(在它之前和之后)。

一个段落内的所有内容都应合并为一行。

我在项目中找到了一些我想要重用的类似代码。但是,我很难弄清楚xPath函数/变量。我真的想把它与Mads提供的代码结合起来。但我失败了。

这是我打算运行的代码。

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:d="ddn:cns-org:v5">
    <xsl:output method="text" omit-xml-declaration="yes"/>

    <!-- ***********************************************************
        Call template process section 
         ************************************************************-->
    <xsl:template match="/">
      <xsl:for-each select="d:abc/d:section">  <!-- Is it OK?-->    
            <xsl:call-template name="process_section"> </xsl:call-template>      
      </xsl:for-each>
    </xsl:template>


     <xsl:template name="process_section">

                <xsl:if test="not(string-length(normalize-space(./section/title))=0)">
                    <xsl:variable name="title" select="string(./section/title)"/>
                    <xsl:value-of
                        select="translate($title, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
                    <xsl:if test="not( substring($title, string-length($title),1)=':' )">
                        <xsl:text>:</xsl:text>
                    </xsl:if>
                    <xsl:text>&#xa;</xsl:text>
                </xsl:if>

                <xsl:if test="not(string-length(normalize-space(./section/title))=0)">
                    <xsl:variable name="title" select="string(./section/title)"/>
                    <xsl:call-template name="TitleCase">
                        <!-- <xsl:with-param name="text" select="./section/title"/> -->
                        <xsl:with-param name="title" select="$title"/>
                        <xsl:with-param name="start" select="true()"/>
                    </xsl:call-template>
                    <xsl:if test="not( substring($title, string-length($title),1)=':' )">
                        <xsl:text>:</xsl:text>
                    </xsl:if>
                    <xsl:text>&#xa;</xsl:text>
                </xsl:if>


        <!-- *****************************************************************************************
          Start processing Text .Paragraph/list under section/text. 
        ****************************************************************************************************-->
        <xsl:for-each select="./section/text/node()">
            <xsl:choose>
                <!-- ************************************************************************************
                    if a node under text is a paragraph
                    *Replace single ':' (no caret / no digit in front) with caret followed by colon '^:'
                    *Also, do not put newline if there is nothing withing paragraph
                    *(level section/text/paragraph or node())
                ******************************************************************************************-->
                <xsl:when test="local-name()='paragraph'">

                    <xsl:for-each
                        select="./content[not(@styleCode='hidden' or @styleCode='bookmark')]">

                        <xsl:choose>


                            <xsl:when test="contains(., ':')">
                                <xsl:call-template name="replaceColon">
                                    <xsl:with-param name="text" select="."/>
                                </xsl:call-template>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="."/>
                            </xsl:otherwise>

                        </xsl:choose>
                    </xsl:for-each>

                    <xsl:if
                        test="(count(./content[not(@styleCode='hidden' or @styleCode='bookmark')]) &gt; 0) or (count(./content)=0)">
                        <xsl:text>&#xa;</xsl:text>
                    </xsl:if>
                </xsl:when>

                <!-- otherwise it has to be list -->
                <xsl:when test="local-name()='list'">
                    <xsl:call-template name="listProcessing"> </xsl:call-template>
                </xsl:when>
            </xsl:choose>

        </xsl:for-each>
        <!-- ********************************************************************
            Done w/ Text (paragraph/list) done. Go back to (level component) 
        **************************************************************************-->


        <xsl:if
            test="string-length(normalize-space(.//content[not(@styleCode='hidden' or @styleCode='bookmark')]/text())) &gt; 0">
            <xsl:text>&#xa;</xsl:text>
        </xsl:if>

        <!-- Subsection. (Level component)  -->
        <xsl:for-each select="./section/component">
            <xsl:if test="not(./section/code/@code='9001')">
                <xsl:call-template name="process_section"/>
            </xsl:if>
        </xsl:for-each>

        <!-- ******************************************
            end of processing component
            *******************************************-->
    </xsl:template>

    <xsl:template name="replaceColon">
        <xsl:param name="text"/>
        <xsl:variable name="before" select="substring-before($text,':')"/>
        <xsl:variable name="after" select="substring-after($text,':')"/>
        <xsl:choose>
            <xsl:when test="contains($before, ':')">
                <xsl:call-template name="replaceColon">
                    <xsl:with-param name="text" select="$before"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:choose>
                    <xsl:when
                        test="string (number(substring($before,string-length($before),1))) != 'NaN'
                        or string (substring($before,string-length($before),1)) = '^'">
                        <xsl:value-of select="$before"/>
                        <xsl:text>:</xsl:text>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="$before"/>
                        <xsl:text>^:</xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:otherwise>
        </xsl:choose>

        <xsl:choose>
            <xsl:when test="contains($after, ':')">
                <xsl:call-template name="replaceColon">
                    <xsl:with-param name="text" select="$after"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$after"/>
            </xsl:otherwise>
        </xsl:choose>

    </xsl:template>

    <!-- *********************************************************
        Begining listProcessing. (Level ./section/text/list)
        *********************************************************** -->
    <xsl:template name="listProcessing">

        <!-- ***iterate each item under list (Level ./section/text/list/item)********* -->
        <xsl:for-each select="./item">
            <xsl:value-of select="position()"/>
            <xsl:value-of select="'. '"/>

            <!-- Checking node under item. (Level ./section/text/list/item/node()) -->
            <xsl:for-each select="./node()">
                <xsl:choose>
                    <!-- ******************************
                        Make sure the paragraph has content, otherwise don't print it or the newline. (CP-5076)
                        ******************************** -->
                    <xsl:when test="local-name(.)='paragraph' and string-length(.)>0">
                        <!-- print paragraph content -->
                        <xsl:for-each
                            select="./content[not(@styleCode='hidden' or @styleCode='bookmark')]">
                            <xsl:choose>
                                <xsl:when test="contains(., ':')">
                                    <xsl:call-template name="replaceColon">
                                        <xsl:with-param name="text" select="."/>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="."/>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:for-each>
                        <xsl:text>&#xa;</xsl:text>
                    </xsl:when>
                    <!-- ******* otherwise it has to be list with a list *********** -->
                    <xsl:when test="local-name(.)='list'">
                        <!-- ******call listProcessing recursively****** -->
                        <xsl:call-template name="listProcessing"/>
                    </xsl:when>
                </xsl:choose>
            </xsl:for-each>
            <!-- node -->
        </xsl:for-each>
        <!-- item -->

        <!-- *********** End listProcessing******** -->
    </xsl:template>


    <!-- *****************************************************
    ******** Title Case**************** *********************
    ****************************************************-->

    <xsl:template name="TitleCase">
        <xsl:param name="title"/>
        <xsl:param name="start"/>

        <xsl:choose>
            <xsl:when test="$start=true()">
                <xsl:choose>
                    <xsl:when test="contains(substring($title,1,1),'[')">
                        <!-- found start bracket -->
                        <xsl:variable name="romanNumneral"
                            select="substring-before(substring-after($title,'['),']')"/>
                        <xsl:value-of select="$romanNumneral"/>
                        <xsl:variable name="title2"
                            select="substring($title,string-length($romanNumneral)+3)"/>
                        <xsl:if test="string-length($title2) > 0">
                            <!-- this is end condition for recursive call -->
                            <xsl:call-template name="TitleCase">
                                <xsl:with-param name="title" select="$title2"/>
                                <xsl:with-param name="start" select="true()"/>
                                <!-- "[IV] axis" in this case it should become "IV Axis", so call with true -->
                            </xsl:call-template>
                        </xsl:if>
                    </xsl:when>
                    <xsl:otherwise>
                        <!-- title case me -->
                        <xsl:value-of
                            select="translate(substring($title,1,1),'abcdefghijklmnopqrstuvwxyz:','ABCDEFGHIJKLMNOPQRSTUVWXYZ:')"/>
                        <xsl:variable name="title2" select="substring($title,2)"/>
                        <xsl:if test="string-length($title2) > 0">
                            <xsl:call-template name="TitleCase">
                                <xsl:with-param name="title" select="$title2"/>
                                <xsl:with-param name="start" select="false()"/>
                            </xsl:call-template>
                        </xsl:if>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>
            <!-- start test ends -->
            <xsl:when test="contains(substring($title,1,1),'[')">
                <!-- roman test -->
                <xsl:variable name="romanNumneral"
                    select="substring-before(substring-after($title,'['),']')"/>
                <xsl:value-of select="$romanNumneral"/>
                <xsl:variable name="title2"
                    select="substring($title,string-length($romanNumneral)+3)"/>
                <xsl:if test="string-length($title2) > 0">
                    <xsl:call-template name="TitleCase">
                        <xsl:with-param name="title" select="$title2"/>
                        <xsl:with-param name="start" select="false()"/>
                    </xsl:call-template>
                </xsl:if>
            </xsl:when>
            <!-- end Roman test -->
            <xsl:otherwise>
                <!-- small-test case start -->
                <xsl:value-of
                    select="translate(string(substring($title,1,1)), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ:', 'abcdefghijklmnopqrstuvwxyz:')"/>
                <xsl:variable name="title2" select="substring($title,2)"/>
                <xsl:if test="string-length($title2) > 0">
                    <xsl:choose>
                        <xsl:when test="not(contains($title2, ']'))">

                            <xsl:value-of
                                select="translate($title2, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ:', 'abcdefghijklmnopqrstuvwxyz:')"/>


                            <!--   <xsl:value-of select="$title2"/> -->
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:call-template name="TitleCase">
                                <xsl:with-param name="title" select="$title2"/>
                                <xsl:with-param name="start" select="false()"/>
                            </xsl:call-template>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:if>
            </xsl:otherwise>
            <!-- small-case test ends here -->
        </xsl:choose>
    </xsl:template>


    </xsl:stylesheet>

请帮助。

谢谢,戴夫

2 个答案:

答案 0 :(得分:1)

XML文档中的元素绑定到命名空间。很容易遗漏,因为没有名称空间前缀,但文档元素上的声明:xmlns="ddn:cns-org:v5"将该元素(及其后代)绑定到该名称空间。

因此,为了在XSLT中使用XPath进行寻址,您需要声明该命名空间并使用命名空间前缀。

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:d="ddn:cns-org:v5">
    <xsl:output method="text" omit-xml-declaration="yes"/>

    <xsl:template match="text()[normalize-space()]">
        <xsl:value-of select="."/>
        <xsl:text>&#xA;</xsl:text>
    </xsl:template>

    <xsl:template match="text()[not(normalize-space())]"/>

    <xsl:template match="d:section">
        <xsl:apply-templates/>
        <xsl:text>&#xA;</xsl:text>
    </xsl:template>

    <xsl:template match="d:title">
        <xsl:value-of select="translate(., 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
        <xsl:if test="not( substring(., string-length(.),1)=':' )">
            <xsl:text>:</xsl:text>
        </xsl:if>
        <xsl:text>&#xA;</xsl:text>
    </xsl:template>

</xsl:stylesheet>

答案 1 :(得分:0)

大家新年快乐。

我修改了Mads提供的代码。它几乎像我期望的那样工作。这是xsl文件的修改版本。

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:d="ddn:cns-org:v5">
    <xsl:output method="text" omit-xml-declaration="yes" />
<!-- 
    <xsl:template match="text()[normalize-space()]">
        <xsl:value-of select="." />
        <xsl:text>&#xA;</xsl:text>
    </xsl:template>
 -->

    <xsl:template match="text()[not(normalize-space())]" />

    <!-- Add a blank line after each section or paragraph-->
    <xsl:template match="d:section | d:paragraph">
        <xsl:apply-templates />
        <xsl:text>&#xA;</xsl:text>
    </xsl:template>

    <!-- 
        Format the contents in <content></content>
     -->
    <xsl:template match="d:content">    
        <xsl:value-of select='normalize-space()'/>          
    </xsl:template>

    <xsl:template match="d:title">      
        <xsl:text>&#xA;&#xA;</xsl:text>
        <xsl:value-of
            select="translate(normalize-space(), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
        <xsl:if test="not( substring(., string-length(.),1)=':' )">
            <xsl:text>:</xsl:text>
        </xsl:if>
        <xsl:text>&#xA;&#xA;</xsl:text>     
    </xsl:template>

</xsl:stylesheet>

以下是xsl。

生成的纯文本

术前诊断:

__白内障。

术后诊断:

__白内障。

OPERATION:

帕氏玻璃体切除术和视网膜前膜切除术。白内障超声乳化术与后房晶状体植入(对照#

外科医生:

博士。 J. R. xxx

出席会议的医生:

麻醉师:

麻醉:

临床说明:

操作程序:

在患者被带到手术室之前,在日间手术室进行局部消毒,麻醉和扩张。

患者用Proviodine制备。然后将患者披上垂褶。特别注意眼睑/睫毛,准备和悬垂。一个窥器被插入了_eye的穹顶。给予结膜下的Xylocaine。在结膜下注射区域进行小结膜切开术。通过腹膜切开术将3cc的2%Xylocaine和0.75%的Marcaine注射到Tenon的子宫下。

腹腔穿刺术在上下进行。使用眼内非保留的Xylocaine。将粘弹性物质注入前房。用3mm角膜刀进入眼睛。前囊膜切除术在粘弹性下进行。进行氢解剖和核的描绘。开始超声乳化。超声乳化时间为_ 秒。在超声乳化完成后,皮质材料被灌注并从眼睛吸出。后囊被抛光。将人工晶状体插入粘弹性体下。人工晶状体屈光力是_ 屈光度。

用镜头拨片将镜头拨到位。然后进行粘弹性的灌溉和抽吸。测试伤口以确保没有伤口泄漏。

2%的Xylocaine和0.75%Marcaine的额外全周麻醉通过peritomy注入Tenon的子宫内。

然后将25号插管置于颞下,颞上和鼻上。在颞下插管中放置输液。

然后进行玻璃体切除术。

__(xxx博士将此区域称为“开放段落” - 删除此信息)

在完成玻璃体切除术后,重新检查周边视网膜以确保没有未经治疗的外周视网膜撕裂或脱离。移除插管。检查巩膜伤口,如果发现伤口渗漏,则用9-0 Vicryl缝线封闭。否则中断9-0 Vicryl缝合线。给予结膜下Decadron和头孢呋辛。

应用补丁和盾牌。

患者离开手术室时状况良好。

附录:

术后局部眼药水:

  1. Maxidex。
  2. Nevanac。
  3. 莫西沙星。
  4. POSTOPERATIVE FOLLOWUP:

    __

    现在回答我昨天发布的关于使用一些现有代码的问题,例如“replaceColon”模板来操纵可能包含一些不需要的冒号(:)的内容。简单地说,我想将“replaceColon”模板应用于每个“内容”节点。

    任何建议。

    最佳

    戴夫