[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Remove node after testing for equality using value fro

Subject: Remove node after testing for equality using value from external xml document
From: "Evans, Martin Chf Tech " <Martin.Evans934@xxxxxx>
Date: Wed, 8 Feb 2006 09:08:58 -0000
xsl remove node
Hi all,

First time post and very much a newbie to xslt, however I have used the
list before with some success.  Anyway to my problem.
I have a fairly large xml document which I need to test a particular
element for equality. If equal I would  like to remove the complete node
and replace it with a comment. If not equal I just copy the node and
move  on.

This I can achive on a singular node/element test, but I would like to
now do it with a list/array of  values using variables embedded in the
template or calling another xml doc and using it's fragment tree.
Here are the sample files, along with my transformation for a singular
value. I am currently using MSXML4.0  called from some VBScript which
seems to work well for the singular condition check, but I do think I'm
going to get some performance problems when carrying out 500 or so
individual checks on the context xml  doc.

Many thanks in advance for any steer in any direction....

Context xml doc

<?xml version="1.0"?>
<XML_Transfer>
 <Table>
  <Row>
   <MANUFACTURER>U1605</MANUFACTURER>
   <HARDWARE_PART_NO>4017B000-004</HARDWARE_PART_NO>
   <SERIAL_NO>340777-2</SERIAL_NO>
   <METRIC_NO>0</METRIC_NO>
   <LIFE_TYPE>FH</LIFE_TYPE>
   <CUMMULATIVE_TOTAL>1651.398</CUMMULATIVE_TOTAL>
   <EXPIRY_VALUE>360000.000</EXPIRY_VALUE>
   <forcenull>EXPIRY_DATE ARISING_FLAG</forcenull></Row>
  <Row>
   <MANUFACTURER>K0999</MANUFACTURER>
   <HARDWARE_PART_NO>P06004OO</HARDWARE_PART_NO>
   <SERIAL_NO>499256</SERIAL_NO>
   <METRIC_NO>0</METRIC_NO>
   <LIFE_TYPE>FH</LIFE_TYPE>
   <CUMMULATIVE_TOTAL>1651.398</CUMMULATIVE_TOTAL>
   <EXPIRY_VALUE>360000.000</EXPIRY_VALUE>
   <forcenull>EXPIRY_DATE ARISING_FLAG</forcenull></Row>
  <Row>
   <MANUFACTURER>K0999</MANUFACTURER>
   <HARDWARE_PART_NO>EJ200-101</HARDWARE_PART_NO>
   <SERIAL_NO>499255</SERIAL_NO>
   <METRIC_NO>0</METRIC_NO>
   <LIFE_TYPE>FH</LIFE_TYPE>
   <CUMMULATIVE_TOTAL>1651.398</CUMMULATIVE_TOTAL>
   <EXPIRY_VALUE>360000.000</EXPIRY_VALUE>
   <forcenull>EXPIRY_DATE ARISING_FLAG</forcenull></Row>
  <Row>
   <MANUFACTURER>K0999</MANUFACTURER>
   <HARDWARE_PART_NO>J52822805-401/HARDWARE_PART_NO>
   <SERIAL_NO>499257</SERIAL_NO>
   <METRIC_NO>0</METRIC_NO>
   <LIFE_TYPE>FH</LIFE_TYPE>
   <CUMMULATIVE_TOTAL>1651.398</CUMMULATIVE_TOTAL>
   <EXPIRY_VALUE>360000.000</EXPIRY_VALUE>
   <forcenull>EXPIRY_DATE ARISING_FLAG</forcenull></Row>
 </Table>
</XML_Transfer>

Second xml doc

<?xml version='1.0'?>
<XML_Transfer>
<Table>
<Row>
  <HARDWARE_PART_NO>300000</HARDWARE_PART_NO>
</Row>
<Row>
  <HARDWARE_PART_NO>MDR134-1</HARDWARE_PART_NO>
</Row>
<Row>
  <HARDWARE_PART_NO>MDR-134-1</HARDWARE_PART_NO>
</Row>
<Row>
  <HARDWARE_PART_NO>P06004OO</HARDWARE_PART_NO>
</Row>
<Row>
  <HARDWARE_PART_NO>300000</HARDWARE_PART_NO>
</Row>
<Row>
  <HARDWARE_PART_NO>8834-04-550/260C-5.0M</HARDWARE_PART_NO>
</Row>
<Row>
  <HARDWARE_PART_NO>J52822805-401</HARDWARE_PART_NO>
</Row>
<Row>
  <HARDWARE_PART_NO>EFP18206-1</HARDWARE_PART_NO>
</Row>
</Table>
</XML_Transfer>


<?xml version="1.0" encoding="utf-16"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" encoding="utf-16" indent="yes"/>
    <xsl:template match="node() | @*">
        <xsl:choose>
            <xsl:when test="self::Row[HARDWARE_PART_NO != 'EJ200-101']">
                <xsl:comment>Structural Part No Removed</xsl:comment>
            </xsl:when>
            <xsl:otherwise>
                <xsl:copy>
                    <xsl:apply-templates
                       select="node() | @*"/>
                </xsl:copy>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>

Martin Evans

Chf Tech Martin Evans
LAIPT FD(Ops) FD(Strike)2a1
Andover (94391) 2270
Civil: 01264 382270

DII email:  DCSA LAIPT FD2a1
Internet email:  Martin.Evans934@xxxxxx


This e-mail was sent from an e-mail address under the control of MOD.
Privileged/In confidence information may be contained in this message.
If you have received this e-mail in error, please destroy all copies in
your possession or control and kindly notify the sender by e-mail.   The
addressee (or individual responsible for delivery of the message to such
person) may not forward, disclose or copy this e-mail to any third party
without prior consent of MOD.  Furthermore, MOD does not accept
liability for any changes made to this e-mail after it was sent.
Please advise immediately if you or your employer do not consent to
Internet e-mail for messages of this kind.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.