Sorry but sed or awk are not appropriate tools for massaging XML data (documents) except for very simple files. Instead you need to transform the document using a XSLT stylesheet processor.
BTW Translation_Type is an element and not an attribute. Assuming that your document is valid and well-formed, here is a stylesheet which will do the transformation that you want.
The only change I made was to add a top-level node called "root" for well-formedness. You should change "root" to the name of your top-level element.
Here is the stylesheet:
Note you may have to change the encoding to suit your data set.
Assuming your document is called test.xml and your stylesheet is called test.xsl, invoking xsltproc test.xsl test.xsl gives the following output:
Note there are some question marks in the output elements. That is because I did not bother setting up the correct locale and code-set on my system to suit your sample data.
Hi,
What is a good way to read elements of an xml file? i did try xmllint it doesnt provide a function to output values of a tree. In the below example when i specify from Family2 I need the name of the father then the output should be DAVE. Appreciate any help provided in this regards.
Many... (6 Replies)
Hi,
I would like to get rid of all comment in an xml file by grep or sed command:
The content seem like this:
<!-- ab cd
ef gh
ij kl -->
Anyone can help?
Thanks and Regards (3 Replies)
I am running a script remotely to do the following
1. Kill all processes by a user
2. Uninstall certain packages
3. FTP over a new file
4. Kill a ldap process that is not allowing my /devdsk/c0t0d0s7 slice to un-mount
5. Unmount /h
6. comment out the slice in vfstab
7. newfs the... (9 Replies)
I have around 25 hosts and each hosts has 4 instance of jboss and 4 different ip attached to it . I need to make some changes to the startup scripts. Any tips appreciated. I have total of 100 instances which bind to 100 different ip address based on instance name.
For example
File1
... (1 Reply)
hi,
i need my bash script to find regex in xml file.. and comment 2 lines before and after the line that contains regex.. can't use # needs to be <!-- at the beginning and --> and the end of the comment.
so eg..
first block
<filter>
<filter-name>MyRegEx</filter-name>
... (11 Replies)
Hi Friends
Im so confused with using 'for' loop in ksh. I have a xml like the following:
<serviceProvider>
<serviceProviderID>1</serviceProviderID>
<serviceProviderName>Balesh</serviceProviderName>
<serviceFeeAmount>30.00</serviceFeeAmount>
</serviceProvider>... (2 Replies)
Hello!
I'd like to modify custom values in a XML config file between comment tags using bash script.
<feature>
<keyboardshortcut>C-m</keyboardshortcut>
<option1>disabled</option2>
<option2>enabled</option2>
</feature>
<!-- bash script features START -->
<feature>
... (2 Replies)
Hi ,
I have an XML like this.
<Request>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<version>v44</version><messageId>7247308192</messageId><timeToLive>72000000000</timeToLive>
</Request>.
I want to extract on version and messageId.
As in my output... (13 Replies)
I am trying to comment out the crontab entries using sed.
I want to comment it out for a particular environment say '/mypath/scripts/'.
Using the full path as pattern, it is working. but using variable it is not working. i have tried double quotes too. but no luck!
$ crontab -l
... (3 Replies)
Hi,
I have a requirement to extract specific element value dynamically from XML message.
Here is the sample message:
<File>
<List>
<main>
<dir>doc/store834/archive</dir>
<count>5</count>
</main>
<main>
<dir>doc/store834/extract</dir>
<count>6</count>
</main>
<main> ... (3 Replies)
Discussion started by: renukeswar
3 Replies
LEARN ABOUT OPENDARWIN
xsltproc
xsltproc(1) General Commands Manual xsltproc(1)NAME
xsltproc - command line xslt processor
SYNOPSIS
xsltproc [-V | -v | -o file | --timing | --repeat | --debug | --novalid | --noout | --maxdepth val | --html | --docbook | --param name
value | --stringparam name value | --nonet | --warnnet | --catalogs | --xinclude | --profile] [stylesheet] [ file1 ] [ file2 ] [ ....
]
INTRODUCTION
xsltproc is a command line tool for applying XSLT stylesheets to XML documents. It is part of libxslt, the XSLT C library for GNOME. While
it was developed as part of the GNOME project, it can operate independently of the GNOME desktop.
xsltproc is invoked from the command line with the name of the stylesheet to be used followed by the name of the file or files to which the
stylesheet is to be applied.
If a stylesheet is included in an XML document with a Stylesheet Processing Instruction, no stylesheet need be named at the command line.
xsltproc will automatically detect the included stylesheet and use it.
By default, output is to stdout. You can specify a file for output using the -o option.
COMMAND LINE OPTIONS -V or --version
Show the version of libxml and libxslt used.
-v or --verbose
Output each step taken by xsltproc in processing the stylesheet and the document.
-o or --output file
Direct output to the file named file. For multiple outputs, also known as "chunking", -o directory/ directs the output files to a
specified directory. The directory must already exist.
--timing
Display the time used for parsing the stylesheet, parsing the document and applying the stylesheet and saving the result. Displayed
in milliseconds.
--repeat
Run the transformation 20 times. Used for timing tests.
--debug
Output an XML tree of the transformed document for debugging purposes.
--novalid
Skip loading the document's DTD.
--noout
Do not output the result.
--maxdepth value
Adjust the maximum depth of the template stack before libxslt concludes it is in an infinite loop. The default is 500.
--html The input document is an HTML file.
--docbook
The input document is DocBook SGML.
--param name value
Pass a parameter of name name and value value to the stylesheet. You may pass multiple name/value pairs up to a maximum of 32. If
the value being passed is a string rather than a node identifier, use --stringparam instead.
--stringparam name value
Pass a paramenter of name name and value value where value is a string rather than a node identifier.
--nonet
Do not use the Internet to fetch DTD's or entities.
--warnnet
Output notification when DTD's or entities are fetched over the Internet.
--catalogs
Use catalogs to resolve the location of external entities. This speeds DTD resolution. By having a catalog file point to a local
version of the DTD, xsltproc does not have to use the Internet to fetch the DTD. xsltproc uses the catalog identified by the envi-
ronmental variable SGML_CATALOG_FILES.
--xinclude
Process the input document using the Xinclude specification. More details on this can be found in the Xinclude specification:
http://www.w3.org/TR/xinclude/.
--profile or --norman
Output profiling information detailing the amount of time spent in each part of the stylesheet. This is useful in optimizing
stylesheet performance.
RETURN VALUES
xsltproc's return codes provide information that can be used when calling it from scripts.
0: normal
1: no argument
2: too many parameters
3: unknown option
4: failed to parse the stylesheet
5: error in the stylesheet
6: error in one of the documents
7: unsupported xsl:output method
8: string parameter contains both quote and double-quotes
MORE INFORMATION
libxml web page: http://www.xmlsoft.org/
W3C XSLT page: http://www.w3.org/TR/xslt
AUTHOR
Copyright 2001 by John Fleck <jfleck@inkstain.net>. This is release 0.2 of the xsltproc Manual.
NOTES
Source for libxslt is available in the SUNWlxslS package. Documentation for libxslt is available on-line at http://xmlsoft.org/XSLT/
2002 Jun 27 xsltproc(1)