Sponsored Content
Full Discussion: XML root element
Top Forums Shell Programming and Scripting XML root element Post 302248558 by fpmurphy on Saturday 18th of October 2008 10:04:07 AM
Old 10-18-2008
Here is a XSL stylesheet which does what you want do. Just change the root element "root" to whatever you need it to be.
Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml"/>

<xsl:template match="/XmlInterchange/Payload/Consols/Consol/Notes/Note/CustomNoteTypeName">
   <xsl:if test=". = 'DBHA' or . = 'DAKO'" >
      <xsl:element name="root">
        <xsl:copy-of select="/*/node()" />
      </xsl:element>
   </xsl:if>
</xsl:template>

<xsl:template match="/">
  <xsl:apply-templates select="/XmlInterchange/Payload/Consols/Consol/Notes/Note/CustomNoteTypeName"/>
</xsl:template>

</xsl:stylesheet>

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

reading and searching xml element text in script

well i have this xml file here: this file is called filereader.xml <?xml version="1.0" encoding="UTF-8"?> <file> <file1> <filecopy>/new/test/thefile.txt</filecopy> <filecopy>/new/test/thefile2.ppt</filecopy> </file1> </file> i need to write the script that search for the Bold text... (2 Replies)
Discussion started by: forevercalz
2 Replies

2. Shell Programming and Scripting

Finding a XML element and moving the file

Hi All, I am looking for a awk/shell which can find an element named REFERENCE in a XML file and check whether it is empty or not. If there is no value in the REFERENCE element then correspondingly move the file to some other folder. The Unix server is AIX version 4. Any inputs... (9 Replies)
Discussion started by: karansachdeva
9 Replies

3. Shell Programming and Scripting

Extract XML Element Values

I have a rather large file with XML-style content. Each line contains one full XML entry. For example: 1:<Message><DNIS>1234</DNIS><UCID>3456</UCID><TransferGroup>XYZXYZ</TransferGroup></Message> 2:<Message><DNIS>9999</DNIS><UCID>2584</UCID><TransferGroup>ABCABC</TransferGroup></Message>... (1 Reply)
Discussion started by: sharpi03
1 Replies

4. UNIX Desktop Questions & Answers

read XML xml element with REGEXP

Hi, I would need to read an xml element from an xml file to a local variable. Please could you help me with a shell script to get so? Considering that I have a file called file.xml like below: <header> <description>This is the description</description> <content>This is the... (2 Replies)
Discussion started by: oscarmon
2 Replies

5. Shell Programming and Scripting

Extracting the Root Element from the XML File

Any help to extract the root element from an XML file will be appreciated. Example: test.xml <?xml version="1.0" encoding="utf-8" ?> <TestXMLMessage> <TestRec> <ID>1000</ID> </TestRec> </TestXMLMessage> Wanted to extract the TestXMLMessage. Regards, Chari (6 Replies)
Discussion started by: sree_chari
6 Replies

6. Shell Programming and Scripting

Need to find root element name of XML file

Given this XML: <?xml version="1.0"?> <catalog> <cd> <title>Empire Burlesque</title> <artist>Bob Dylan</artist> <country>USA</country> <company>Columbia</company> <price>10.90</price> <year>1985</year> </cd> <cd> <title>Hide your heart</title> ... (2 Replies)
Discussion started by: ricksj
2 Replies

7. UNIX for Advanced & Expert Users

Perl XML::DOM: How to test if element exists?

Hi, I'm trying to write a script for some xml file handling, but I'm not getting too far with it. I've got the following xml content <?xml version="1.0" encoding="UTF-8"?> <Test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <Operation name="OPER1"> <Action name="ACTION1">... (2 Replies)
Discussion started by: Juha
2 Replies

8. Shell Programming and Scripting

Find if XML element has a matching required element

I want to check if every <Part> element has corresponding <Description> in this sample XML. ....<Lot Of XML> <Inv lineNumber="2"> <Item> ... (4 Replies)
Discussion started by: kchinnam
4 Replies

9. UNIX for Dummies Questions & Answers

Extract Element from XML file

<?xml version = '1.0' encoding =... (8 Replies)
Discussion started by: Siva SQL
8 Replies

10. Shell Programming and Scripting

How to insert a CSV within xml element tag using Python?

Hi Team, I have a CSV file which I have to read through and needs to insert the content within an XML file using Python ONLY ( as most of the code base we have in python only). I managed to find the first part, missing how to insert to XML under "specific" tags. cat input.csv... (0 Replies)
Discussion started by: panyam
0 Replies
TEXT-VIMCOLOR(1p)					User Contributed Perl Documentation					 TEXT-VIMCOLOR(1p)

NAME
text-vimcolor - command-line program to syntax color a file in HTML, XML or PDF SYNOPSIS
$ text-vimcolor --format html --full-page FILENAME > OUTPUT.html $ text-vimcolor --format xml FILENAME > OUTPUT.xml $ text-vimcolor --format pdf FILENAME --output OUTPUT.pdf DESCRIPTION
This program uses the Vim text editor to highlight text according to its syntax, and turn the highlighting into HTML, XML or PDF output. It works with any file type which Vim itself can highlight. Usually Vim will be able to autodetect the file format based on the filename (and sometimes the contents of the file). Exactly one filename should be given on the command line to name the input file. If none is given input will instead be read from stdin (the standard input). If Vim can't guess the file type automatically, it can be specified explicitly using the "--filetype" option. For example: $ text-vimcolor --format html --filetype prolog foo.pl > foo.html This program is a command line interface to the Perl module Text::VimColor. OPTIONS
The following options are understood: --help Show a summary of the usage, including a list of options. --debug Turns on debugging in the underlying Perl module. This makes it print the command used to run Vim. --filetype file-type Set the type of the file explicitly. The file-type argument should be something which Vim will recognise when set with its "filetype" option. Examples are "perl", "cpp" (for C++) and "sh" (for Unix shell scripts). These names are case sensitive, and should usually be all-lowercase. --format output-format The output format to generate. Must be one of the following: html Generate XHTML output, with text marked with "<span>" elements with "class" attributes. A CSS stylesheet should be used to define the coloring, etc., for the output. See the "--full-page" option below. xml Output is in a simple XML vocabulary. This can then be used by other software to do further transformations (e.g., using XSLT). pdf XML output is generated and fed to the FOP XSL-FO processor, with an appropriate XSL style sheet. The stylesheet uses XSLT to transform the normal XML output into XSL-FO, which is then rendered to PDF. For this to work, the command "fop" must be available. An output file must be specified with "--output" with this format. Full details of the HTML and XML output formats can be found in the documentation for Text::VimColor. --output output-filename Specifies the name of the output file (which will end up containing either HTML, XML or PDF). If this option is omitted, the output will be sent to stdout (the standard output). This option is required when the output format is PDF (because of limitations in FOP). --full-page When the output format is HTML, this option will make the output a complete HTML page, rather than just a fragment of HTML. A CSS stylesheet will be inserted inline into the output, so the output will be useable as it is. --no-inline-stylesheet When the output format is HTML and "--fullpage" is given, a stylesheet is normally inserted in-line in the output file. If this option is given it will instead be referenced with a "<link>" element. --let name=value When Vim is run the value of name will be set to value using Vim's "let" command. More than one of these options can be set. The value is not quoted or escaped in any way, so it can be an expression. These settings take precedence over "--unlet" options. This option corresponds to the "vim_let" setting and method in the Perl module. --unlet name Prevent the value of name being set with Vim's "let" command. This can be used to turn off default settings. This option corresponds to the "vim_let" setting and method in the Perl module, when used with a value of "undef". BUGS
o The PDF output option often doesn't work, because it is dependent on FOP, which often doesn't work. This is also why it is mind numbingly slow. o FOP (0.20.3) seems to ignore the "background-color" property on "<fo:inline>". If that's what it's meant to do, how do you set the background color on part of a line? AUTHOR
Geoff Richards <qef@laxan.com> COPYRIGHT
Copyright 2002-2006, Geoff Richards. This program is free software; you can redistribute it and/or modify it under the same terms as Perl. perl v5.10.1 2006-02-19 TEXT-VIMCOLOR(1p)
All times are GMT -4. The time now is 10:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy