xref: /aoo41x/main/udm/source/xml/xmlitem.cxx (revision 898949d6)
1*898949d6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*898949d6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*898949d6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*898949d6SAndrew Rist  * distributed with this work for additional information
6*898949d6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*898949d6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*898949d6SAndrew Rist  * "License"); you may not use this file except in compliance
9*898949d6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*898949d6SAndrew Rist  *
11*898949d6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*898949d6SAndrew Rist  *
13*898949d6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*898949d6SAndrew Rist  * software distributed under the License is distributed on an
15*898949d6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*898949d6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*898949d6SAndrew Rist  * specific language governing permissions and limitations
18*898949d6SAndrew Rist  * under the License.
19*898949d6SAndrew Rist  *
20*898949d6SAndrew Rist  *************************************************************/
21*898949d6SAndrew Rist 
22*898949d6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include <precomp.h>
25cdf0e10cSrcweir #include <udm/xml/xmlitem.hxx>
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES
28cdf0e10cSrcweir #include <cosv/file.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 
31cdf0e10cSrcweir namespace csi
32cdf0e10cSrcweir {
33cdf0e10cSrcweir namespace xml
34cdf0e10cSrcweir {
35cdf0e10cSrcweir 
36cdf0e10cSrcweir char cReplacable[256] =
37cdf0e10cSrcweir 	{
38cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,	// 0 - 49
39cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,
40cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,
41cdf0e10cSrcweir 	  0,  0,  0,  0,  1,  	0,  0,  0,  1,  0,    	// ", &
42cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,
43cdf0e10cSrcweir 
44cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,	// 50 - 99
45cdf0e10cSrcweir 	  1,  0,  1,  0,  0,  	0,  0,  0,  0,  0,	  	// <, >
46cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,
47cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,
48cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,
49cdf0e10cSrcweir 
50cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,  // 100 - 149
51cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,
52cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,
53cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,
54cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,
57cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,
58cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,
59cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,
60cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,
63cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,
64cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,
65cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,
66cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	0,  0,  0,  0,  0,
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 	  0,  0,  0,  0,  0,  	1					// &nbsp;
69cdf0e10cSrcweir 	};
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 
72cdf0e10cSrcweir class MultiItem : public Item
73cdf0e10cSrcweir {
74cdf0e10cSrcweir   public:
75cdf0e10cSrcweir 						MultiItem();
76cdf0e10cSrcweir 						~MultiItem();
77cdf0e10cSrcweir 
Add(DYN Item * let_dpDatum)78cdf0e10cSrcweir 	void				Add(
79cdf0e10cSrcweir 							DYN Item *			let_dpDatum )
80cdf0e10cSrcweir 													{ csv_assert( let_dpDatum != 0 );
81cdf0e10cSrcweir 													  aItems.push_back(let_dpDatum); }
Erase()82cdf0e10cSrcweir 	void				Erase()						{ aItems.erase_all(); }
83cdf0e10cSrcweir 
84cdf0e10cSrcweir   private:
85cdf0e10cSrcweir 	virtual void		do_WriteOut(
86cdf0e10cSrcweir 							csv::bostream &			io_aFile ) const;
87cdf0e10cSrcweir 	// DATA
88cdf0e10cSrcweir 	ItemList			aItems;
89cdf0e10cSrcweir };
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 
92cdf0e10cSrcweir void					StreamOut(
93cdf0e10cSrcweir 							Dyn< Item >  &			o_rContent,
94cdf0e10cSrcweir 							DYN Item *				let_dpItem );
95cdf0e10cSrcweir inline void
StreamOut(AttrList & o_rAttrs,DYN Attribute * let_dpAttr)96cdf0e10cSrcweir StreamOut( AttrList &				o_rAttrs,
97cdf0e10cSrcweir 		   DYN Attribute *			let_dpAttr )
98cdf0e10cSrcweir {
99cdf0e10cSrcweir 	csv_assert( let_dpAttr != 0 );
100cdf0e10cSrcweir 	o_rAttrs.push_back( let_dpAttr );
101cdf0e10cSrcweir }
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 
104cdf0e10cSrcweir inline void
Impl_SetContent(Dyn<Item> & o_rContent,DYN Item * let_dpItem)105cdf0e10cSrcweir Impl_SetContent( Dyn< Item >  &			o_rContent,
106cdf0e10cSrcweir 				 DYN Item *				let_dpItem )
107cdf0e10cSrcweir {
108cdf0e10cSrcweir 	o_rContent = let_dpItem;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 
112cdf0e10cSrcweir //*********************		Attribute		****************************//
113cdf0e10cSrcweir 
114cdf0e10cSrcweir const String   attrValueBegin("=\"");
115cdf0e10cSrcweir const String   attrValueEnd("\"");
116cdf0e10cSrcweir 
117cdf0e10cSrcweir void
WriteOut(csv::bostream & io_aFile) const118cdf0e10cSrcweir Attribute::WriteOut( csv::bostream & io_aFile ) const
119cdf0e10cSrcweir {
120cdf0e10cSrcweir 	io_aFile.write( Name() );
121cdf0e10cSrcweir     if ( Value().length() > 0 )
122cdf0e10cSrcweir     {
123cdf0e10cSrcweir 	    io_aFile.write( attrValueBegin );
124cdf0e10cSrcweir 	    io_aFile.write( Value() );
125cdf0e10cSrcweir 	    io_aFile.write( attrValueEnd );
126cdf0e10cSrcweir     }
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 
131cdf0e10cSrcweir //************************		Element		****************************//
132cdf0e10cSrcweir 
133cdf0e10cSrcweir const String    newline("\n");
134cdf0e10cSrcweir const String    space(" ");
135cdf0e10cSrcweir const String    beginTagBegin("<");
136cdf0e10cSrcweir const String    endTagBegin("</");
137cdf0e10cSrcweir const String    tagEnd(">");
138cdf0e10cSrcweir const String    emptyTagEnd("/>");
139cdf0e10cSrcweir 
140cdf0e10cSrcweir void
do_WriteOut(csv::bostream & io_aFile) const141cdf0e10cSrcweir Element::do_WriteOut( csv::bostream & io_aFile ) const
142cdf0e10cSrcweir {
143cdf0e10cSrcweir 	io_aFile.write( beginTagBegin );
144cdf0e10cSrcweir 	io_aFile.write( inq_TagName() );
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 	const AttrList * pAttrs = inq_Attrs();
147cdf0e10cSrcweir 	if ( pAttrs != 0 )
148cdf0e10cSrcweir 	{
149cdf0e10cSrcweir 		for ( AttrList::iterator it = pAttrs->begin();
150cdf0e10cSrcweir 			  it != pAttrs->end();
151cdf0e10cSrcweir 			  ++it )
152cdf0e10cSrcweir 		{
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 			io_aFile.write( space );
155cdf0e10cSrcweir 			(*it)->WriteOut( io_aFile );
156cdf0e10cSrcweir 		}
157cdf0e10cSrcweir 	}
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 	const Item * pContent = inq_Content();
160cdf0e10cSrcweir 	if ( pContent != 0 )
161cdf0e10cSrcweir 		io_aFile.write( tagEnd );
162cdf0e10cSrcweir 	else
163cdf0e10cSrcweir     {
164cdf0e10cSrcweir      	if (FinishEmptyTag_XmlStyle())
165cdf0e10cSrcweir     		io_aFile.write( emptyTagEnd );
166cdf0e10cSrcweir         else
167cdf0e10cSrcweir         {
168cdf0e10cSrcweir     		io_aFile.write( tagEnd );
169cdf0e10cSrcweir     		io_aFile.write( endTagBegin );
170cdf0e10cSrcweir         	io_aFile.write( inq_TagName() );
171cdf0e10cSrcweir     		io_aFile.write( tagEnd );
172cdf0e10cSrcweir         }
173cdf0e10cSrcweir     }
174cdf0e10cSrcweir 	if ( LineBreakAfterBeginTag() )
175cdf0e10cSrcweir 		io_aFile.write( newline );
176cdf0e10cSrcweir 	if ( pContent == 0 )
177cdf0e10cSrcweir 		return;
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 	pContent->WriteOut( io_aFile );
180cdf0e10cSrcweir 	io_aFile.write( endTagBegin );
181cdf0e10cSrcweir 	io_aFile.write( inq_TagName() );
182cdf0e10cSrcweir 	io_aFile.write( tagEnd );
183cdf0e10cSrcweir 	if ( LineBreakAfterEndTag() )
184cdf0e10cSrcweir 		io_aFile.write( newline );
185cdf0e10cSrcweir }
186cdf0e10cSrcweir 
187cdf0e10cSrcweir bool
FinishEmptyTag_XmlStyle() const188cdf0e10cSrcweir Element::FinishEmptyTag_XmlStyle() const
189cdf0e10cSrcweir {
190cdf0e10cSrcweir  	return true;
191cdf0e10cSrcweir }
192cdf0e10cSrcweir 
193cdf0e10cSrcweir bool
LineBreakAfterBeginTag() const194cdf0e10cSrcweir Element::LineBreakAfterBeginTag() const
195cdf0e10cSrcweir {
196cdf0e10cSrcweir 	return false;
197cdf0e10cSrcweir }
198cdf0e10cSrcweir 
199cdf0e10cSrcweir bool
LineBreakAfterEndTag() const200cdf0e10cSrcweir Element::LineBreakAfterEndTag() const
201cdf0e10cSrcweir {
202cdf0e10cSrcweir 	return LineBreakAfterBeginTag();
203cdf0e10cSrcweir }
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 
206cdf0e10cSrcweir //************************		EmptyElement		****************************//
207cdf0e10cSrcweir 
208cdf0e10cSrcweir void
op_streamout(DYN Item *)209cdf0e10cSrcweir EmptyElement::op_streamout( DYN Item *	)
210cdf0e10cSrcweir {
211cdf0e10cSrcweir 	// Does nothing.
212cdf0e10cSrcweir }
213cdf0e10cSrcweir 
214cdf0e10cSrcweir void
op_streamout(DYN Attribute * let_dpAttr)215cdf0e10cSrcweir EmptyElement::op_streamout( DYN Attribute * let_dpAttr )
216cdf0e10cSrcweir {
217cdf0e10cSrcweir 	StreamOut( inq_RefAttrs(), let_dpAttr );
218cdf0e10cSrcweir }
219cdf0e10cSrcweir 
220cdf0e10cSrcweir void
do_SetContent(DYN Item *)221cdf0e10cSrcweir EmptyElement::do_SetContent( DYN Item *	)
222cdf0e10cSrcweir {
223cdf0e10cSrcweir 	// Does nothing.
224cdf0e10cSrcweir }
225cdf0e10cSrcweir 
226cdf0e10cSrcweir const Item *
inq_Content() const227cdf0e10cSrcweir EmptyElement::inq_Content() const
228cdf0e10cSrcweir {
229cdf0e10cSrcweir 	return 0;
230cdf0e10cSrcweir }
231cdf0e10cSrcweir 
232cdf0e10cSrcweir const AttrList *
inq_Attrs() const233cdf0e10cSrcweir EmptyElement::inq_Attrs() const
234cdf0e10cSrcweir {
235cdf0e10cSrcweir     return & const_cast< EmptyElement* >(this)->inq_RefAttrs();
236cdf0e10cSrcweir }
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 
239cdf0e10cSrcweir //************************		PureElement		****************************//
240cdf0e10cSrcweir 
241cdf0e10cSrcweir void
op_streamout(DYN Item * let_dpItem)242cdf0e10cSrcweir PureElement::op_streamout( DYN Item * let_dpItem )
243cdf0e10cSrcweir {
244cdf0e10cSrcweir 	StreamOut( inq_RefContent(), let_dpItem );
245cdf0e10cSrcweir }
246cdf0e10cSrcweir 
247cdf0e10cSrcweir void
op_streamout(DYN Attribute *)248cdf0e10cSrcweir PureElement::op_streamout( DYN Attribute * )
249cdf0e10cSrcweir {
250cdf0e10cSrcweir 	// Does nothing.
251cdf0e10cSrcweir }
252cdf0e10cSrcweir 
253cdf0e10cSrcweir void
do_SetContent(DYN Item * let_dpItem)254cdf0e10cSrcweir PureElement::do_SetContent( DYN Item *	let_dpItem )
255cdf0e10cSrcweir {
256cdf0e10cSrcweir 	Impl_SetContent( inq_RefContent(), let_dpItem );
257cdf0e10cSrcweir }
258cdf0e10cSrcweir 
259cdf0e10cSrcweir const Item *
inq_Content() const260cdf0e10cSrcweir PureElement::inq_Content() const
261cdf0e10cSrcweir {
262cdf0e10cSrcweir     return const_cast< PureElement* >(this)->inq_RefContent().Ptr();
263cdf0e10cSrcweir }
264cdf0e10cSrcweir 
265cdf0e10cSrcweir const AttrList *
inq_Attrs() const266cdf0e10cSrcweir PureElement::inq_Attrs() const
267cdf0e10cSrcweir {
268cdf0e10cSrcweir 	return 0;
269cdf0e10cSrcweir }
270cdf0e10cSrcweir 
271cdf0e10cSrcweir 
272cdf0e10cSrcweir //***************************		SglTag		**************************//
273cdf0e10cSrcweir 
274cdf0e10cSrcweir void
op_streamout(DYN Item *)275cdf0e10cSrcweir SglTag::op_streamout( DYN Item * )
276cdf0e10cSrcweir {
277cdf0e10cSrcweir 	// Does nothing.
278cdf0e10cSrcweir }
279cdf0e10cSrcweir 
280cdf0e10cSrcweir void
op_streamout(DYN Attribute *)281cdf0e10cSrcweir SglTag::op_streamout( DYN Attribute * )
282cdf0e10cSrcweir {
283cdf0e10cSrcweir 	// Does nothing.
284cdf0e10cSrcweir }
285cdf0e10cSrcweir 
286cdf0e10cSrcweir void
do_SetContent(DYN Item *)287cdf0e10cSrcweir SglTag::do_SetContent( DYN Item *)
288cdf0e10cSrcweir {
289cdf0e10cSrcweir 	// Does nothing.
290cdf0e10cSrcweir }
291cdf0e10cSrcweir 
292cdf0e10cSrcweir const Item *
inq_Content() const293cdf0e10cSrcweir SglTag::inq_Content() const
294cdf0e10cSrcweir {
295cdf0e10cSrcweir 	return 0;
296cdf0e10cSrcweir }
297cdf0e10cSrcweir 
298cdf0e10cSrcweir const AttrList *
inq_Attrs() const299cdf0e10cSrcweir SglTag::inq_Attrs() const
300cdf0e10cSrcweir {
301cdf0e10cSrcweir 	return 0;
302cdf0e10cSrcweir }
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 
305cdf0e10cSrcweir //***************************		AnElement		**************************//
306cdf0e10cSrcweir 
AnElement(const String & i_sTagName)307cdf0e10cSrcweir AnElement::AnElement( const String &   i_sTagName )
308cdf0e10cSrcweir 	:	sTagName( i_sTagName )
309cdf0e10cSrcweir 		// pContent,
310cdf0e10cSrcweir 		// aAttrs
311cdf0e10cSrcweir {
312cdf0e10cSrcweir }
313cdf0e10cSrcweir 
AnElement(const char * i_sTagName)314cdf0e10cSrcweir AnElement::AnElement( const char * i_sTagName )
315cdf0e10cSrcweir 	:	sTagName( i_sTagName )
316cdf0e10cSrcweir 		// pContent,
317cdf0e10cSrcweir 		// aAttrs
318cdf0e10cSrcweir {
319cdf0e10cSrcweir }
320cdf0e10cSrcweir 
~AnElement()321cdf0e10cSrcweir AnElement::~AnElement()
322cdf0e10cSrcweir {
323cdf0e10cSrcweir }
324cdf0e10cSrcweir 
325cdf0e10cSrcweir void
op_streamout(DYN Item * let_dpItem)326cdf0e10cSrcweir AnElement::op_streamout( DYN Item *	let_dpItem )
327cdf0e10cSrcweir {
328cdf0e10cSrcweir 	StreamOut( pContent, let_dpItem );
329cdf0e10cSrcweir }
330cdf0e10cSrcweir 
331cdf0e10cSrcweir void
op_streamout(DYN Attribute * let_dpAttr)332cdf0e10cSrcweir AnElement::op_streamout( DYN Attribute * let_dpAttr )
333cdf0e10cSrcweir {
334cdf0e10cSrcweir 	StreamOut( aAttrs, let_dpAttr );
335cdf0e10cSrcweir }
336cdf0e10cSrcweir 
337cdf0e10cSrcweir void
do_SetContent(DYN Item * let_dpItem)338cdf0e10cSrcweir AnElement::do_SetContent( DYN Item * let_dpItem )
339cdf0e10cSrcweir {
340cdf0e10cSrcweir 	Impl_SetContent( pContent, let_dpItem );
341cdf0e10cSrcweir }
342cdf0e10cSrcweir 
343cdf0e10cSrcweir const String &
inq_TagName() const344cdf0e10cSrcweir AnElement::inq_TagName() const
345cdf0e10cSrcweir {
346cdf0e10cSrcweir 	return sTagName;
347cdf0e10cSrcweir }
348cdf0e10cSrcweir 
349cdf0e10cSrcweir const Item *
inq_Content() const350cdf0e10cSrcweir AnElement::inq_Content() const
351cdf0e10cSrcweir {
352cdf0e10cSrcweir 	return pContent.Ptr();
353cdf0e10cSrcweir }
354cdf0e10cSrcweir 
355cdf0e10cSrcweir const AttrList *
inq_Attrs() const356cdf0e10cSrcweir AnElement::inq_Attrs() const
357cdf0e10cSrcweir {
358cdf0e10cSrcweir 	return &aAttrs;
359cdf0e10cSrcweir }
360cdf0e10cSrcweir 
361cdf0e10cSrcweir 
362cdf0e10cSrcweir //***************************     AnEmptyElement	**************************//
363cdf0e10cSrcweir 
AnEmptyElement(const String & i_sTagName)364cdf0e10cSrcweir AnEmptyElement::AnEmptyElement( const String &   i_sTagName )
365cdf0e10cSrcweir 	:	sTagName( i_sTagName )
366cdf0e10cSrcweir 		// aAttrs
367cdf0e10cSrcweir {
368cdf0e10cSrcweir }
369cdf0e10cSrcweir 
AnEmptyElement(const char * i_sTagName)370cdf0e10cSrcweir AnEmptyElement::AnEmptyElement( const char * i_sTagName )
371cdf0e10cSrcweir 	:	sTagName( i_sTagName )
372cdf0e10cSrcweir 		// aAttrs
373cdf0e10cSrcweir {
374cdf0e10cSrcweir }
375cdf0e10cSrcweir 
~AnEmptyElement()376cdf0e10cSrcweir AnEmptyElement::~AnEmptyElement()
377cdf0e10cSrcweir {
378cdf0e10cSrcweir 
379cdf0e10cSrcweir }
380cdf0e10cSrcweir 
381cdf0e10cSrcweir const String &
inq_TagName() const382cdf0e10cSrcweir AnEmptyElement::inq_TagName() const
383cdf0e10cSrcweir {
384cdf0e10cSrcweir 	return sTagName;
385cdf0e10cSrcweir }
386cdf0e10cSrcweir 
387cdf0e10cSrcweir AttrList &
inq_RefAttrs()388cdf0e10cSrcweir AnEmptyElement::inq_RefAttrs()
389cdf0e10cSrcweir {
390cdf0e10cSrcweir 	return aAttrs;
391cdf0e10cSrcweir }
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 
394cdf0e10cSrcweir //***************************     APureElement	 	**************************//
395cdf0e10cSrcweir 
APureElement(const String & i_sTagName)396cdf0e10cSrcweir APureElement::APureElement( const String &   i_sTagName )
397cdf0e10cSrcweir 	:	sTagName( i_sTagName )
398cdf0e10cSrcweir 		// pContent
399cdf0e10cSrcweir {
400cdf0e10cSrcweir }
401cdf0e10cSrcweir 
APureElement(const char * i_sTagName)402cdf0e10cSrcweir APureElement::APureElement( const char * i_sTagName )
403cdf0e10cSrcweir 	:	sTagName( i_sTagName )
404cdf0e10cSrcweir 		// pContent
405cdf0e10cSrcweir {
406cdf0e10cSrcweir }
407cdf0e10cSrcweir 
~APureElement()408cdf0e10cSrcweir APureElement::~APureElement()
409cdf0e10cSrcweir {
410cdf0e10cSrcweir }
411cdf0e10cSrcweir 
412cdf0e10cSrcweir const String &
inq_TagName() const413cdf0e10cSrcweir APureElement::inq_TagName() const
414cdf0e10cSrcweir {
415cdf0e10cSrcweir 	return sTagName;
416cdf0e10cSrcweir }
417cdf0e10cSrcweir 
418cdf0e10cSrcweir Dyn< Item > &
inq_RefContent()419cdf0e10cSrcweir APureElement::inq_RefContent()
420cdf0e10cSrcweir {
421cdf0e10cSrcweir 	return pContent;
422cdf0e10cSrcweir }
423cdf0e10cSrcweir 
424cdf0e10cSrcweir 
425cdf0e10cSrcweir 
426cdf0e10cSrcweir //***************************     ASglTag	 		**************************//
427cdf0e10cSrcweir 
ASglTag(const String & i_sTagName)428cdf0e10cSrcweir ASglTag::ASglTag( const String &   i_sTagName )
429cdf0e10cSrcweir 	:	sTagName( i_sTagName )
430cdf0e10cSrcweir {
431cdf0e10cSrcweir }
432cdf0e10cSrcweir 
ASglTag(const char * i_sTagName)433cdf0e10cSrcweir ASglTag::ASglTag( const char *  i_sTagName )
434cdf0e10cSrcweir 	:	sTagName( i_sTagName )
435cdf0e10cSrcweir {
436cdf0e10cSrcweir }
437cdf0e10cSrcweir 
~ASglTag()438cdf0e10cSrcweir ASglTag::~ASglTag()
439cdf0e10cSrcweir {
440cdf0e10cSrcweir }
441cdf0e10cSrcweir 
442cdf0e10cSrcweir const String &
inq_TagName() const443cdf0e10cSrcweir ASglTag::inq_TagName() const
444cdf0e10cSrcweir {
445cdf0e10cSrcweir 	return sTagName;
446cdf0e10cSrcweir }
447cdf0e10cSrcweir 
448cdf0e10cSrcweir 
449cdf0e10cSrcweir //***************************		AnAttribute		**************************//
AnAttribute(const String & i_sName,const String & i_sValue)450cdf0e10cSrcweir AnAttribute::AnAttribute( const String &   i_sName,
451cdf0e10cSrcweir 						  const String &   i_sValue )
452cdf0e10cSrcweir 	:	sName(i_sName),
453cdf0e10cSrcweir 	    sValue(i_sValue)
454cdf0e10cSrcweir {
455cdf0e10cSrcweir }
456cdf0e10cSrcweir 
AnAttribute(const char * i_sName,const char * i_sValue)457cdf0e10cSrcweir AnAttribute::AnAttribute( const char * i_sName,
458cdf0e10cSrcweir 						  const char * i_sValue )
459cdf0e10cSrcweir 	:	sName(i_sName),
460cdf0e10cSrcweir 	    sValue(i_sValue)
461cdf0e10cSrcweir {
462cdf0e10cSrcweir }
463cdf0e10cSrcweir 
~AnAttribute()464cdf0e10cSrcweir AnAttribute::~AnAttribute()
465cdf0e10cSrcweir {
466cdf0e10cSrcweir }
467cdf0e10cSrcweir 
468cdf0e10cSrcweir const String &
inq_Name() const469cdf0e10cSrcweir AnAttribute::inq_Name() const
470cdf0e10cSrcweir {
471cdf0e10cSrcweir 	return sName;
472cdf0e10cSrcweir }
473cdf0e10cSrcweir 
474cdf0e10cSrcweir const String &
inq_Value() const475cdf0e10cSrcweir AnAttribute::inq_Value() const
476cdf0e10cSrcweir {
477cdf0e10cSrcweir 	return sValue;
478cdf0e10cSrcweir }
479cdf0e10cSrcweir 
480cdf0e10cSrcweir 
481cdf0e10cSrcweir 
482cdf0e10cSrcweir //***************************		Text		**************************//
483cdf0e10cSrcweir 
Text(const String & i_sText)484cdf0e10cSrcweir Text::Text( const String &   i_sText )
485cdf0e10cSrcweir 	:	sText(i_sText)
486cdf0e10cSrcweir {
487cdf0e10cSrcweir }
488cdf0e10cSrcweir 
Text(const char * i_sText)489cdf0e10cSrcweir Text::Text( const char * i_sText )
490cdf0e10cSrcweir 	:	sText(i_sText)
491cdf0e10cSrcweir {
492cdf0e10cSrcweir }
493cdf0e10cSrcweir 
~Text()494cdf0e10cSrcweir Text::~Text()
495cdf0e10cSrcweir {
496cdf0e10cSrcweir }
497cdf0e10cSrcweir 
498cdf0e10cSrcweir void
do_WriteOut(csv::bostream & io_aFile) const499cdf0e10cSrcweir Text::do_WriteOut( csv::bostream & io_aFile ) const
500cdf0e10cSrcweir {
501cdf0e10cSrcweir 	const unsigned char *
502cdf0e10cSrcweir 	    pStart = reinterpret_cast< const unsigned char* >(sText.c_str());
503cdf0e10cSrcweir 	const unsigned char *
504cdf0e10cSrcweir 	    pOut = pStart;
505cdf0e10cSrcweir 
506cdf0e10cSrcweir 	for ( ; *pOut != '\0'; ++pOut )
507cdf0e10cSrcweir 	{
508cdf0e10cSrcweir 		if ( cReplacable[*pOut] )
509cdf0e10cSrcweir 		{
510cdf0e10cSrcweir 			if ( pOut != pStart )
511cdf0e10cSrcweir 			{
512cdf0e10cSrcweir 				io_aFile.write( pStart, pOut-pStart );
513cdf0e10cSrcweir 			}
514cdf0e10cSrcweir 
515cdf0e10cSrcweir 			switch (*pOut)
516cdf0e10cSrcweir 			{
517cdf0e10cSrcweir 				case '<': 	io_aFile.write("&lt;");		break;
518cdf0e10cSrcweir 				case '>':   io_aFile.write("&gt;");		break;
519cdf0e10cSrcweir 				case '"':   io_aFile.write("&quot;");	break;
520cdf0e10cSrcweir 				case '&':   io_aFile.write("&amp;");	break;
521cdf0e10cSrcweir 				case 255:   io_aFile.write("&nbsp;");	break;
522cdf0e10cSrcweir 			}
523cdf0e10cSrcweir 
524cdf0e10cSrcweir 			pStart = pOut+1;
525cdf0e10cSrcweir 		}	// endif (cReplacable[*pOut])
526cdf0e10cSrcweir 	}	// end for
527cdf0e10cSrcweir 
528cdf0e10cSrcweir 	if ( pOut != pStart )
529cdf0e10cSrcweir 	{
530cdf0e10cSrcweir 		io_aFile.write( pStart, pOut-pStart );
531cdf0e10cSrcweir 	}
532cdf0e10cSrcweir }
533cdf0e10cSrcweir 
534cdf0e10cSrcweir 
535cdf0e10cSrcweir //***************************		XmlCode		**************************//
536cdf0e10cSrcweir 
XmlCode(const String & i_sText)537cdf0e10cSrcweir XmlCode::XmlCode( const String &   i_sText )
538cdf0e10cSrcweir 	:	sText(i_sText)
539cdf0e10cSrcweir {
540cdf0e10cSrcweir }
541cdf0e10cSrcweir 
XmlCode(const char * i_sText)542cdf0e10cSrcweir XmlCode::XmlCode( const char *     i_sText )
543cdf0e10cSrcweir 	:	sText(i_sText)
544cdf0e10cSrcweir {
545cdf0e10cSrcweir }
546cdf0e10cSrcweir 
~XmlCode()547cdf0e10cSrcweir XmlCode::~XmlCode()
548cdf0e10cSrcweir {
549cdf0e10cSrcweir }
550cdf0e10cSrcweir 
551cdf0e10cSrcweir void
do_WriteOut(csv::bostream & io_aFile) const552cdf0e10cSrcweir XmlCode::do_WriteOut( csv::bostream & io_aFile ) const
553cdf0e10cSrcweir {
554cdf0e10cSrcweir 	io_aFile.write(sText);
555cdf0e10cSrcweir }
556cdf0e10cSrcweir 
557cdf0e10cSrcweir 
558cdf0e10cSrcweir //***************************		MultiItem		**************************//
559cdf0e10cSrcweir 
MultiItem()560cdf0e10cSrcweir MultiItem::MultiItem()
561cdf0e10cSrcweir {
562cdf0e10cSrcweir }
563cdf0e10cSrcweir 
~MultiItem()564cdf0e10cSrcweir MultiItem::~MultiItem()
565cdf0e10cSrcweir {
566cdf0e10cSrcweir }
567cdf0e10cSrcweir 
568cdf0e10cSrcweir void
do_WriteOut(csv::bostream & io_aFile) const569cdf0e10cSrcweir MultiItem::do_WriteOut( csv::bostream &	io_aFile ) const
570cdf0e10cSrcweir {
571cdf0e10cSrcweir 	ItemList::iterator itEnd = aItems.end();
572cdf0e10cSrcweir 
573cdf0e10cSrcweir 	for ( ItemList::iterator it = aItems.begin();
574cdf0e10cSrcweir 		  it != itEnd;
575cdf0e10cSrcweir 		  ++it )
576cdf0e10cSrcweir 	{
577cdf0e10cSrcweir 		(*it)->WriteOut( io_aFile );
578cdf0e10cSrcweir 	}
579cdf0e10cSrcweir 
580cdf0e10cSrcweir }
581cdf0e10cSrcweir 
582cdf0e10cSrcweir 
583cdf0e10cSrcweir 
584cdf0e10cSrcweir //***************************		Helpers		**************************//
585cdf0e10cSrcweir 
586cdf0e10cSrcweir void
StreamOut(Dyn<Item> & o_rContent,DYN Item * let_dpItem)587cdf0e10cSrcweir StreamOut( Dyn< Item >  &			o_rContent,
588cdf0e10cSrcweir 		   DYN Item *				let_dpItem )
589cdf0e10cSrcweir {
590cdf0e10cSrcweir 	MultiItem * pContent = 0;
591cdf0e10cSrcweir 	if ( bool(o_rContent) )
592cdf0e10cSrcweir 	{
593cdf0e10cSrcweir 		pContent = static_cast< MultiItem* >( o_rContent.MutablePtr() );
594cdf0e10cSrcweir 		csv_assert( dynamic_cast< MultiItem* >( o_rContent.MutablePtr() ) != 0 );
595cdf0e10cSrcweir 	}
596cdf0e10cSrcweir 	else
597cdf0e10cSrcweir 	{
598cdf0e10cSrcweir 		pContent = new MultiItem;
599cdf0e10cSrcweir 		o_rContent = pContent;
600cdf0e10cSrcweir 	}
601cdf0e10cSrcweir 
602cdf0e10cSrcweir 	csv_assert( let_dpItem != 0 );
603cdf0e10cSrcweir 	pContent->Add( let_dpItem );
604cdf0e10cSrcweir }
605cdf0e10cSrcweir 
606cdf0e10cSrcweir 
607cdf0e10cSrcweir 
608cdf0e10cSrcweir 
609cdf0e10cSrcweir }   // namespace xml
610cdf0e10cSrcweir }   // namespace csi
611