RE: [xsl] gathering entities when transforming

Subject: RE: [xsl] gathering entities when transforming
From: cknell@xxxxxxxxxx
Date: Wed, 22 Jun 2005 16:47:33 -0400
I left out the processing instructions to save space. Here is a stylesheet that does what you ask for.

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:output method="xml" indent="yes" encoding="UTF-8" />
  <xsl:strip-space elements="*" />

  <xsl:template match="/">
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template match="diagnosticwp">
    <xsl:copy>
      <xsl:for-each select="@*">
        <xsl:copy />
      </xsl:for-each>
      <xsl:apply-templates />
    </xsl:copy>
  </xsl:template>

  <xsl:template match="statemanipulation">
    <xsl:copy>
      <xsl:apply-templates />
    </xsl:copy>
  </xsl:template>

  <xsl:template match="string">
    <expression>
      <xsl:copy-of select="." />
    </expression>
  </xsl:template>

</xsl:stylesheet>
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Carolyn Oliver <Coliver@xxxxxxxxx>
Sent:     Wed, 22 Jun 2005 16:12:11 -0400
To:       <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject:  [xsl] gathering entities when transforming

I have an XML file that I need to add another layer of elements to.  The
XML currently is:

<?xml version="1.0" encoding="utf-8"?>
<!--ArborText, Inc., 1988-2002, v.4002-->
<!DOCTYPE diagnosticwp SYSTEM
"Production_Rev_3061_MIL-STD-40051-2361C.dtd"[
<!ENTITY obj.5  SYSTEM "G:\EMS2\FMTV20\GRAPHICS\E\CHORD.wmf" NDATA WMF>
<!ENTITY obj.6  SYSTEM "G:\EMS2\FMTV20\GRAPHICS\E\R2e8801.wmf" NDATA
WMF>
<!ENTITY obj.7  SYSTEM "G:\EMS2\FMTV20\GRAPHICS\E\R2e8802.wmf" NDATA
WMF>
<!ENTITY obj.8  SYSTEM "G:\EMS2\FMTV20\GRAPHICS\E\R2e8801.wmf" NDATA
WMF>
<!ENTITY obj.9  SYSTEM "G:\EMS2\FMTV20\GRAPHICS\E\R2e8802.wmf" NDATA
WMF>
<!ENTITY obj.10  SYSTEM "G:\EMS2\FMTV20\GRAPHICS\E\R2e8803.wmf" NDATA
WMF>
]>
<?Pub Inc?>
<diagnosticwp wpno="e88-20">
<statemanipulation>
<string>foobar</string>
</statemanipulation>
</diagnosticwp>
..

What I want is:

<?xml version="1.0" encoding="utf-8"?>
<!--ArborText, Inc., 1988-2002, v.4002-->
<!DOCTYPE diagnosticwp SYSTEM
"Production_Rev_3061_MIL-STD-40051-2361C.dtd"[
<!ENTITY obj.5  SYSTEM "G:\EMS2\FMTV20\GRAPHICS\E\CHORD.wmf" NDATA WMF>
<!ENTITY obj.6  SYSTEM "G:\EMS2\FMTV20\GRAPHICS\E\R2e8801.wmf" NDATA
WMF>
<!ENTITY obj.7  SYSTEM "G:\EMS2\FMTV20\GRAPHICS\E\R2e8802.wmf" NDATA
WMF>
<!ENTITY obj.8  SYSTEM "G:\EMS2\FMTV20\GRAPHICS\E\R2e8801.wmf" NDATA
WMF>
<!ENTITY obj.9  SYSTEM "G:\EMS2\FMTV20\GRAPHICS\E\R2e8802.wmf" NDATA
WMF>
<!ENTITY obj.10  SYSTEM "G:\EMS2\FMTV20\GRAPHICS\E\R2e8803.wmf" NDATA
WMF>
]>
<?Pub Inc?>
<diagnosticwp wpno="e88-20">
<statemanipulation>
<expression>                                   <<<< new tag
<string>foobar</string>
</expression>
</statemanipulation>
</diagnosticwp>
..

How do I get the entities in my new file?  If I do a copy-of the root,
I'll get the entire file won't I?  Just using the copy is giving me:

<?xml version="1.0" encoding="utf-8"?>
<!--ArborText, Inc., 1988-2002, v.4002-->
<!DOCTYPE diagnosticwp SYSTEM
"Production_Rev_3061_MIL-STD-40051-2361C.dtd">
<?Pub Inc?>
<diagnosticwp wpno="e88-20">
<statemanipulation>
<expression>
<string>foobar</string>
</expression>
</statemanipulation>
</diagnosticwp>
..

Thanks for any help you can offer.

Carolyn



**********************************************************************
Confidentiality Notice
The information contained in this e-mail is confidential and intended for
use only by the person(s) or organization listed in the address. If you have
received this communication in error, please contact the sender at O'Neil &
Associates, Inc., immediately. Any copying, dissemination, or distribution
of this communication, other than by the intended recipient, is strictly
prohibited.
**********************************************************************

Current Thread