XML attribute quote?

U

udupi_mail

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.
 
M

Martin Honnen

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.
 
U

udupi_mail

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.
 
P

Peter Flynn

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,840
Latest member
BrendanG78

Latest Threads

Top