Subject: RE: [xsl] FW: Using a processing instruction to remove a node From: "Michael Kay" <mhk@xxxxxxxxx> Date: Thu, 15 Jan 2004 17:41:03 -0000 |
You want <xsl:template match="node"> <xsl:copy-of select="."/> </xsl:template> <xsl:template match="node[preceding-sibling::node() [not(self::text())][1] [self::processing-instruction('REMOVE')]]"/> I.e. if the first node (other than text nodes) before the node in question is a processing instruction, don't copy it. Michael Kay > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of > Beyer,Nathan > Sent: 15 January 2004 16:48 > To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] FW: Using a processing instruction to remove a node > > > > I have an XML document with a processing instruction that > precedes a node that I'd like removed, but I'm having trouble > with the XSL. Any help would be appreciated. Thanks. > > Here's an example of the XML document. > <?xml version="1.0" encoding="UTF-8"?> > <root> > <node value="1"> > <inner-node>1</inner-node> > </node> > <?REMOVE?> > <node value="2"> > <inner-node>2 - remove me</inner-node> > </node> > <node2 value="3"> > <inner-node>3</inner-node> > </node2> > <node2 value="4"> > <inner-node>4</inner-node> > </node2> > </root> > > This is the result I want. > <?xml version="1.0" encoding="UTF-8"?> > <root> > <node value="1"> > <inner-node>1</inner-node> > </node> > <node2 value="3"> > <inner-node>3</inner-node> > </node2> > <node2 value="4"> > <inner-node>4</inner-node> > </node2> > </root> > > Here's the XSL I have currently. > <?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" encoding="UTF-8"/> > <xsl:template match="node()"> > <xsl:copy> > <xsl:copy-of select="@*"/> > <xsl:apply-templates > select="node()[not(preceding-sibling::processing-instruction(' > REMOVE'))] > "/> > </xsl:copy> > </xsl:template> > <xsl:template match="processing-instruction('REMOVE')"> > </xsl:template> > </xsl:stylesheet> > > Here's the result that I'm getting. > <?xml version="1.0" encoding="UTF-8"?> > <root> > <node value="1"> > <inner-node>1</inner-node> > </node> > </root> > > CONFIDENTIALITY NOTICE > > This message and any included attachments > are from Cerner Corporation and are intended > only for the addressee. The information > contained in this message is confidential and > may constitute inside or non-public information > under international, federal, or state > securities laws. Unauthorized forwarding, > printing, copying, distribution, or use of such > information is strictly prohibited and may be > unlawful. If you are not the addressee, please > promptly delete this message and notify the > sender of the delivery error by e-mail or you > may call Cerner's corporate offices in Kansas > City, Missouri, U.S.A at (+1) (816)221-1024. > ---------------------------------------- -- > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] FW: Using a processing in, David Carlisle | Thread | RE: [xsl] FW: Using a processing in, Beyer,Nathan |
RE: [xsl] [HELP] Preserving charact, Michael Kay | Date | RE: [xsl] FW: Using a processing in, Beyer,Nathan |
Month |