You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Verker, Anat" <Av...@ndsisrael.com> on 2003/06/17 12:09:29 UTC

Attribute value containing new lines

Hi,

I've encountered a problem when using new lines in attribute value.
This is a fragment from the original xml file I used:

<text text1="aaa&#xA;bbb&#xA;ccc"/>

According to the Attribute-Value Normalization algorithm (http://www.w3.org/TR/REC-xml#AVNormalize) a character reference (i.e. &#xA;) is replaced with the referenced character (i.e. 0xA).
After parsing, I write the content to a file (using the sample code of SAXPrintHandlers). The value written to the file doesn't contain &#xA; but 0xA.
Then I parse the xml again, but not the original xml file, but the file that I previously created. Now, according to the Attribute-Value Normalization algorithm, 0xA is replaced with a space character, which means that I'm losing my new line.

This is the code fragment where I write the attribute values:

// attributes is of type AttributeList
// fFormatter is of type XMLFormatter

for (unsigned int i = 0; i < attributes.getLength(); i++) {
	fFormatter
		<< XMLFormatter::NoEscapes
		<< chSpace << attributes.getName(i)
		<< chEqual << chDoubleQuote
		<< XMLFormatter::AttrEscapes
		<< attributes.getValue(i)
		<< XMLFormatter::NoEscapes
		<< chDoubleQuote;
}

I tried replacing each 0xA with &#xA; before writing the attribute value to the formatter, but then I got the following output:
<text text1="aaa&amp;#xA;bbb&amp;#xA;ccc"/>
When I omitted XMLFormatter::AttrEscapes I got the following output:
<text text1="aaa&#xA;bbb&#xA;ccc"/>
This is actually what I want but I'm not sure that omitting XMLFormatter::AttrEscapes is the right solution (it can harm other things, can't it?).

Please advise.

Thanks,
Anat Verker.
***********************************************************************************
Information contained in this email message is intended only for use of the individual or entity named above. If the reader of this message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the postmaster@ndsisrael.com and destroy the original message.
***********************************************************************************

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Attribute value containing new lines

Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,
	could you open a bug on this so it does not get lost.

cheers,


Gareth


On Tue, 17 Jun 2003, Verker, Anat wrote:

> Hi,
> 
> I've encountered a problem when using new lines in attribute value.
> This is a fragment from the original xml file I used:
> 
> <text text1="aaa&#xA;bbb&#xA;ccc"/>
> 
> According to the Attribute-Value Normalization algorithm (http://www.w3.org/TR/REC-xml#AVNormalize) a character reference (i.e. &#xA;) is replaced with the referenced character (i.e. 0xA).
> After parsing, I write the content to a file (using the sample code of SAXPrintHandlers). The value written to the file doesn't contain &#xA; but 0xA.
> Then I parse the xml again, but not the original xml file, but the file that I previously created. Now, according to the Attribute-Value Normalization algorithm, 0xA is replaced with a space character, which means that I'm losing my new line.
> 
> This is the code fragment where I write the attribute values:
> 
> // attributes is of type AttributeList
> // fFormatter is of type XMLFormatter
> 
> for (unsigned int i = 0; i < attributes.getLength(); i++) {
> 	fFormatter
> 		<< XMLFormatter::NoEscapes
> 		<< chSpace << attributes.getName(i)
> 		<< chEqual << chDoubleQuote
> 		<< XMLFormatter::AttrEscapes
> 		<< attributes.getValue(i)
> 		<< XMLFormatter::NoEscapes
> 		<< chDoubleQuote;
> }
> 
> I tried replacing each 0xA with &#xA; before writing the attribute value to the formatter, but then I got the following output:
> <text text1="aaa&amp;#xA;bbb&amp;#xA;ccc"/>
> When I omitted XMLFormatter::AttrEscapes I got the following output:
> <text text1="aaa&#xA;bbb&#xA;ccc"/>
> This is actually what I want but I'm not sure that omitting XMLFormatter::AttrEscapes is the right solution (it can harm other things, can't it?).
> 
> Please advise.
> 
> Thanks,
> Anat Verker.
> ***********************************************************************************
> Information contained in this email message is intended only for use of the individual or entity named above. If the reader of this message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the postmaster@ndsisrael.com and destroy the original message.
> ***********************************************************************************
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> 
> 
> 

-- 
Gareth Reakes, Head of Product Development  +44-1865-203192
DecisionSoft Limited                        http://www.decisionsoft.com
XML Development and Services




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Some getting started questions.

Posted by "Thomas F. O'Connell" <tf...@netcentral.com>.
In my opinion, this is a great all around XML reference. Make sure to
get the 3rd Edition.

I'm not really able to answer your other questions, though.

-tfo

On Tue, 2003-06-17 at 08:09, Olav Benum wrote:

> *What about XML Companion by Neil Bradley?  



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Some getting started questions.

Posted by Olav Benum <ol...@yahoo.com>.
Greetings!

These are a kind of beginners question ... not on
Xerces-C but on if I should use Xerces-C, and
about XML,  XML Schema and the XML / C++ combination.

*************************************************

This is an application that uses text-files in a 
proprietary format to store information, this format
and supporting logic should be converted to XML,
some of the files should be manipulated as DOM.
The code should be cross-platform C++ (Windows Mac
OS/X).  My own environment is Visual C++ 7.1

Myself I know some XML, but not much  about Schema and
DOM.

My plan is to use XML-Spy to write Schemas and XML,
and use the code generation for Xerxes-C.

*Is this a good choice?  What would be the main 
 alternatives?
 
Instead of XML-Spy I might use what comes with VS, 
also we might use some Qt in the project, but 
I think it (the Qt XML libraries) are more low-end
than Xerxes-C..........
  
*Should I read up on / know about  other technologies 
 than DOM and Schema?
 
*For learning, should I just start to work with Xerxes
C and XML-Spy, or should I read books on Schema and
DOM?
 
*BOOKS*

*How is C++ XML by Fabio Arciniegas? 
 Is it outdated?  How old books should I consider?
 
*What about XML Companion by Neil Bradley?  

*The Official XMLSPY Handbook by  Larry Kim? 

*Other books? should I read more about Schema?

************************************************************

The actual legacy files has one  type which contains
information about printers, including information 
about possible value in the second type of files which

are for papers that can be printed on these printers.

So there would be one base schema, XML files for the
printers containing a mix of Schema and other XML
constructs, and XML files for the papers referring to
one such printer XML...

These possible values in the paper files are
combination of a restricted list of tag-values, to 
many to write out every combination.  

How easy is it to express this in Schema compared 
to writing  my own XML constructs adopted to the 
specs i get (How expressive is Schema)?

Generally the important thing is generating valid
paper documents.
Validation is just "nice to have".

Is it correct that such generation only comes with 
DOM level 3, not  jet implemented in Xerces-C?  
Also is it so that validation of DOM is not supported
in Xerces-C?  

Am I left with  using the DOM of the Schemas
to generate my documents?

Any technologies that might be better in this respect?

Thanks for your time
Olav


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org