I tried with sed command to create a space between namespace from the XML file. I used this syntax. Can someone tell me is this syntax is vaild?
/usr/xpg4/bin/sed -e 's/<\/^.*><^.:Errort>/<\/^.*> <^.:Errort>/g' test > test2
I dint find any changes or any space being created between these namespace.
Maybe with something like this:
sed 's/><^.:Errort>/> <^.:Errort>/g' test > test2
Result is the same, Space is not getting created when i used
<^.:Errort>
But space will get created when i used the exact expression , something like this.
<ns1:Errot>
But this expression ns1 changes in many of the scenarios, so instead of this I need to use Regex. Can you get me the exact regex that needs to be used.
Try:
sed 's/><[^>]*:Errort>/> <^.:Errort>/g' test > test2
This works for me:
sed 's/\(<\/[^>]*>\)\(<[^:]*:\)/\1 \2/g' test > test2
Regards,
Mark.
Thanks for your precious input, both of your syntax worked very well.
Mark
Can you explain me the syntax, since your syntax worked for both opening and closing namespace.
---------- Post updated 04-21-11 at 12:00 AM ---------- Previous update was 04-20-11 at 11:47 PM ----------
Mark,
Your syntax has created one space between all the namespaces, but indeed i just required particularly for this namespace <ns1:Errort> </ns1:Errort>
Earlier you wrote:
I took that to mean that you wanted a space between all namespaces. So I'm not quite clear on what you're asking for exactly.
Here are some more options:
sed 's/\(<\/[^>]*>\)\(<[^:]*:Errort\)/\1 \2/g' test > test2
sed 's/\(<\/[^>]*>\)\(<ns[0-9]*:Errort\)/\1 \2/g' test > test2
sed 's/\(<\/[^>]*>\)\(<ns1:Errort\)/\1 \2/g' test > test2
Regards,
Mark.
Syntax
sed 's/\(<\/[^>]*>\)\(<[^:]*:Errort\)/\1 \2/g' test > test2
Worked well, but need to check other way round now. Do this syntax work? This syntax is for closing namespace <\ns1:Errort>
sed 's/(<\/[^:]*:Errort\)/\(<\/[^>]*>\)/\1 \2/g' test2 > test7
Not sure I understand. What do you mean by the other way around?
The first syntax is to create a space between two tags where <ns1:Errort> tag starts, which works fine with
Sample 1: Worked really well.
sed 's/\(<\/[^>]*>\)\(<[^:]*:Errort\)/\1 \2/g' test > test2
</tg1:XYZ123><ns1:Errort>
The other way round syntax which i mean is for creating a space for closing </ns1:Errort> tag. Which is something like this.
Sample 2: Not sure, there is something wrong with this, syntax is being garbled.
sed 's/(<\/[^:]*:Errort\)/\(<\/[^>]*>\)/\1 \2/g' test2 > test7
</ns1:Errort><tg2:123XYZ>
Ok, understood. Try:
sed -e 's/>\(<[^:]*:Errort\)/> \1/g' -e 's/\(<\/[^:]*:Errort>\)</\1 </g'
Regards,
Mark.
1 Like