Sponsored Content
Top Forums Shell Programming and Scripting Remove lines from XML based on condition Post 302447885 by fpmurphy on Tuesday 24th of August 2010 03:05:48 PM
Old 08-24-2010
if you need to remove the empty elements using a stylesheet, here is one way of doing it
Code:
<?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" />
   <xsl:strip-space elements="*" />

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

   <xsl:template match="acd">
      <xsl:if test="acdID/node()">
         <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
         </xsl:copy>
      </xsl:if>
      <xsl:if test="not(acdID/node())">
      </xsl:if>
   </xsl:template>

</xsl:stylesheet>

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to search then remove based on condition

Folks; I'm trying to write a script to scan through a directory tree then for each file it finds, it run a command line tool, then if the results include the word "DONE", it removes the file. In more details; i have a Linux directory tree such as "/opt/grid/1022/store" I'm trying to write a... (6 Replies)
Discussion started by: Katkota
6 Replies

2. Shell Programming and Scripting

Perl XML, find matching condition and grep lines and put the lines somewhere else

Hi, my xml files looks something like this <Instance Name="New York"> <Description></Description> <Instance Name="A"> <Description></Description> <PropertyValue Key="false" Name="Building A" /> </Instance> <Instance Name="B"> ... (4 Replies)
Discussion started by: tententen
4 Replies

3. Shell Programming and Scripting

extract xml tag based on condition

Hi All, I have a large xml file of invoices. The file looks like below: <INVOICES> <INVOICE> <NAME>Customer A</NAME> <INVOICE_NO>1234</INVOICE_NO> </INVOICE> <INVOICE> <NAME>Customer A</NAME> <INVOICE_NO>2345</INVOICE_NO> </INVOICE> <INVOICE> <NAME>Customer A</NAME>... (9 Replies)
Discussion started by: angshuman
9 Replies

4. Shell Programming and Scripting

Replace text inside XML file based on condition

Hi All, I want to change the name as SEQ_13 ie., <Property Name="Name">SEQ_13</Property> when the Stage Type is PxSequentialFile ie., <Property Name="StageType">PxSequentialFile</Property> :wall: Input.XML <Main> <Record Identifier="V0S13" Type="CustomStage" Readonly="0">... (3 Replies)
Discussion started by: kmsekhar
3 Replies

5. Shell Programming and Scripting

Check the value in xml based on condition

Hi, I have a log file having n number of xml's like the one below. <uOStatus xmlns:env="http://abc.org/def/ghi/"... (3 Replies)
Discussion started by: Neethu
3 Replies

6. Shell Programming and Scripting

Print certain lines based on condition

Hi All, I have following listing Filesystem GB blocks Free Used Iused Iused Mounted on /dev/hd2 4.00 0.31 93 63080 43 /usr Filesystem GB blocks Free Used Iused Iused Mounted on Filesystem GB blocks Free Used Iused Iused... (11 Replies)
Discussion started by: ckwan
11 Replies

7. Shell Programming and Scripting

Remove line based on condition in awk

In the following tab-delimited input, I am checking $7 for the keyword intronic. If that keyword is found then $2 is split by the . in each line and if the string after the digits or the +/- is >10, then that line is deleted. This will always be the case for intronic. If $7 is exonic then nothing... (10 Replies)
Discussion started by: cmccabe
10 Replies

8. Shell Programming and Scripting

Help with XML tag value extraction based on matching condition

sample xml file part <DocumentMinorVersion>0</DocumentMinorVersion> <DocumentVersion>1</DocumentVersion> <EffectiveDate>2017-05-30T00:00:00Z</EffectiveDate> <FollowOnFrom> <ContractRequest _LoadId="export_AJ6iAFoh6g0rE9"> <_LocalId>CRW2218451</_LocalId> ... (4 Replies)
Discussion started by: paul1234
4 Replies

9. Shell Programming and Scripting

Help with XML tag value extraction based on condition

sample xml file part <?xml version="1.0" encoding="UTF-8"?><ContractWorkspace xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" _LoadId="export_AJ6iAFmh+pQHq1" xsi:noNamespaceSchemaLocation="ContractWorkspace.xsd"> <_LocalId>CW2218471</_LocalId> <Active>true</Active> ... (3 Replies)
Discussion started by: paul1234
3 Replies

10. Shell Programming and Scripting

Help with tag value extraction from xml file based on a matching condition

Hi , I have a situation where I need to search an xml file for the presence of a tag <FollowOnFrom> and also , presence of partial part of the following tag <ContractRequest _LoadId and if these 2 exist ,then extract the value from the following tag <_LocalId> which is "CW2094139". There... (2 Replies)
Discussion started by: paul1234
2 Replies
edoc_doclet(3erl)					     Erlang Module Definition						 edoc_doclet(3erl)

NAME
edoc_doclet - Standard doclet module for EDoc. DESCRIPTION
Standard doclet module for EDoc. DATA TYPES
doclet_gen() = #doclet_gen{sources=[string()], app=no_app() | atom(), packages=[atom()], modules=[atom()], modules=[atom()], filemap=function()} : doclet_toc() = #doclet_gen{paths=[string()], indir=string()} : edoc_context() = #context{dir=string(), env=edoc_env() (see module edoc_lib), opts=[term()]} : no_app() : A value used to mark absence of an Erlang application context. Use the macro NO_APP defined in edoc_doclet.hrl to produce this value. EXPORTS
run(Command::doclet_gen() | doclet_toc(), Ctxt::edoc_context()) -> ok Main doclet entry point. See the file edoc_doclet.hrl for the data structures used for passing parameters. Also see edoc:layout/2 for layout-related options, and edoc:get_doc/2 for options related to reading source files. Options: {file_suffix, string()} : Specifies the suffix used for output files. The default value is ".html" . {hidden, boolean()} : If the value is true , documentation of hidden modules and functions will also be included. The default value is false . {overview, edoc:filename()} : Specifies the name of the overview-file. By default, this doclet looks for a file "overview.edoc" in the target directory. {private, boolean()} : If the value is true , documentation of private modules and functions will also be included. The default value is false . {stylesheet, string()} : Specifies the URI used for referencing the stylesheet. The default value is "stylesheet.css" . If an empty string is specified, no stylesheet reference will be generated. {stylesheet_file, edoc:filename()} : Specifies the name of the stylesheet file. By default, this doclet uses the file "stylesheet.css" in the priv subdirectory of the EDoc installation directory. The named file will be copied to the target directory. {title, string()} : Specifies the title of the overview-page. SEE ALSO
edoc AUTHORS
Richard Carlsson <richardc@it.uu.se > edoc 0.7.7 edoc_doclet(3erl)
All times are GMT -4. The time now is 09:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy