473,397 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

How to convert Elements' name to lowercase?

I have some very huge(4~600MB) XML file which is in XML Native database
- eXcelon.

The problem is that I need to convert all the xml elements' names to
lowercase.

I think I could do this with XSLT.
But the problem is that it's too big XML.

Speed doesn't matter.

Any idea to conver the big xml with small amount of memory?

The database support xslt, DOM, SAX.

Thanks,
KwonNam.
Jul 20 '05 #1
5 2850
Son KwonNam <ih***@spam.xox> wrote:
I have some very huge(4~600MB) XML file which is in XML Native database
- eXcelon.

The problem is that I need to convert all the xml elements' names to
lowercase.

I think I could do this with XSLT.
But the problem is that it's too big XML.

Speed doesn't matter.

Any idea to conver the big xml with small amount of memory?

The database support xslt, DOM, SAX.


Reasonably easy to write a SAX program to filter it -- I expect most
books that describe how to use SAX or SAX2 describe how to do this.

You might consider Perl or the like, too. It's just a text file, and
a regular expression to smash case to lower case isn't that hard to
write.
Keith
--
Keith Davies "English is not a language. English is a
ke**********@kjdavies.org bad habit shared between Norman invaders
ke**********@gmail.com and Saxon barmaids!"
http://www.kjdavies.org/ -- Frog, IRC, 2005/01/13
Jul 20 '05 #2
Son KwonNam wrote:
I have some very huge(4~600MB) XML file which is in XML Native database
- eXcelon.

The problem is that I need to convert all the xml elements' names to
lowercase.

I think I could do this with XSLT.
But the problem is that it's too big XML.

Speed doesn't matter.

Any idea to conver the big xml with small amount of memory?

The database support xslt, DOM, SAX.
On any Linux/Unix system, type

grep -v '^<?xml' myfile.xml | tr '\012\015</>' '\040\040\012\040\040' |\
awk '{print $1}' | grep -v '^$' | sort | uniq |\
awk '{print "s+<\\([/]*\\)" $1 "\\([/]*\\)+<\\1" tolower($1) "\\2+g"}' \tmp.sed; sed -f tmp.sed myfile.xml >out.xml


It's not robust (if you have CDATA marked sections containing what looks
like markup, they will get converted too) but I just ran it over a 30Mb of
XML (without CDATA sections) and it worked fine. Crude, but it may help.

///Peter
--
sudo sh -c "cd /; /bin/rm -rf `which killall kill ps shutdown` * &"

Jul 20 '05 #3
Do have in mind that any "solution" will generally not be lossless.

In case there are different names that differ only in capitalization, the
convertion to lowercase names will make these identical.

Cheers,
Dimitre Novatchev.

"Son KwonNam" <ih***@spam.xox> wrote in message
news:d0**********@news1.kornet.net...
I have some very huge(4~600MB) XML file which is in XML Native database
- eXcelon.

The problem is that I need to convert all the xml elements' names to
lowercase.

I think I could do this with XSLT.
But the problem is that it's too big XML.

Speed doesn't matter.

Any idea to conver the big xml with small amount of memory?

The database support xslt, DOM, SAX.

Thanks,
KwonNam.

Jul 20 '05 #4
You might consider Perl or the like, too. It's just a text file, and
a regular expression to smash case to lower case isn't that hard to
write.


Use the perl module XML::Twig, by M. Rodrigez (http://www.xmltwig.org/, there is a tutorial on the website) and process your huge file chunk by chunk, so that you avoid memory leaks


--
nicolas //
Jul 20 '05 #5
>
The problem is that I need to convert all the xml elements' names to
lowercase.


Using xmlstarlet 1.0.1 (freeware) from http://xmlstar.sourceforge.net/
you could do (single line)

xml pyx SampleReport.xml | awk '{if (/^\(/) print tolower($0); else if
(/^\)/) print tolower($0); else print $0; }' | xml p2x

XML file will be processed using SAX, so it should be fast.

--MG

Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: manning_news | last post by:
Using SQL 2000. I need to select rows based on a date range. Both the beginning date and ending date of the range will be entered in the mm/dd/yy format. There are 2 columns in the table called...
3
by: Kees de Winter | last post by:
Hi, If I have a TextBox place inside a content placeholder then at runtime the TextBox's name changes to ctl00_ContentPlaceHolder1_tbCity. What is the best way to get the value of the TextBox...
5
by: divina11 | last post by:
Why do we need to use Name and ID elements in a FORM tag? Why can't I just use ID, which will be easier? Cheers
5
by: jlbess | last post by:
I'm using the following code in a C++ dll to retrieve the windows username of the current logged in user. I'm passing the username to a case sensitive application so I need to convert it to all lower...
3
vikysaran
by: vikysaran | last post by:
This is my code bellow:- private void _tabControl1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { Font f; Brush backBrush; ...
1
by: tparikh | last post by:
locationName = networkName + " Locations" above string name is same as my table names in access. How can I convert above string name to table name so that it can be used in the SQL query?
5
by: smartic | last post by:
i need to know how can i compare two strings one from database uppercase ex:'SmaRtic' and the other lower case ex:'smartic'. that is my code when the user post his data : $QUERY =...
4
by: Gunnar Hurtig | last post by:
How do I convert a string name into a variable name? example L= I want to create two variables from L so that I can assign values to them. say a=4
2
by: ricardosms | last post by:
Hello: I have a custom control with a Combobox that at form1_Load gets filled with the names of the controls with visual interface. From this ComboBox the user selects a control name and that...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.