You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by dave <ce...@yahoo.com> on 2008/03/10 08:41:56 UTC

[is this a bug?] Re: xs:string - Isn't whitespaces preserved by default?

Isn't it a bug with XmlBeans in that xs:string type
have whitespace chars removed when written using
xmlText/other means? 

As per w3c standard, xs:string should have whitespace
chars preserved by default. We don't need to define
'preserve' facets for this situation.

-D
--- Jacob Danner <ja...@gmail.com> wrote:

> How are you generating the XML. I'm not positive its
> whitespace is
> preserved if something like xmlText() is used.
> I might try something like an xs:normalizedString
> and the whitespace=preserve.
> -jacobd
> 
> On Wed, Feb 27, 2008 at 4:57 PM, dave
> <ce...@yahoo.com> wrote:
> >
> >  I have an xs:string type element to hold some
> regex
> >  expressions. I haven't put any
> restrictions/facets for
> >  this xs:string type. Isn't by default, it should
> >  preserve whitespace? Looks like the leading and
> >  trailing spaces are removed when I generate an
> XML
> >  using XmlBeans apis.
> >
> >  In general, what is the better XSD data type to
> hold
> >  regex patterns? Is it just xs:string OR should I
> >  explicitly preserve Whitespace for this
> xs:string?
> >
> >
> >      
>
____________________________________________________________________________________
> >  Be a better friend, newshound, and
> >  know-it-all with Yahoo! Mobile.  Try it now. 
>
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
> >
> >
> > 
>
---------------------------------------------------------------------
> >  To unsubscribe, e-mail:
> user-unsubscribe@xmlbeans.apache.org
> >  For additional commands, e-mail:
> user-help@xmlbeans.apache.org
> >
> >
> 
> 
> 
> -- 
> I'm competing in a Half-Ironman distance triathlon
> to raise money for
> the fight against cancer!
> Please help support my efforts by going to:
> http://www.active.com/donate/tntwaak/jacobd
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail:
> user-help@xmlbeans.apache.org
> 
> 



      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: XmlCursor.insertElementWithText().. why should it insert CDATA??

Posted by Radu Preotiuc-Pietro <ra...@bea.com>.
In this case, "normal text insertion" means CDATA. See my previous post
titled 


Re: XMLBEANS 2.3.0 and CDATA issue

Radu

On Mon, 2008-03-17 at 14:21 -0700, dave wrote:
>  If I try to use this API under an Element of type
> xs:ANY, it inserts the Text as CDATA. Is there any API
> that can insert the element Text without CDATA
> container in this situation? 
> 
>  I just want normal Text insertion like: 
>   <arb> text </arb>
> 
> -D
> 
> 
>       ____________________________________________________________________________________
> Never miss a thing.  Make Yahoo your home page. 
> http://www.yahoo.com/r/hs
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 

Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


XmlCursor.insertElementWithText().. why should it insert CDATA??

Posted by dave <ce...@yahoo.com>.
 If I try to use this API under an Element of type
xs:ANY, it inserts the Text as CDATA. Is there any API
that can insert the element Text without CDATA
container in this situation? 

 I just want normal Text insertion like: 
  <arb> text </arb>

-D


      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


RE: [is this a bug?] Re: xs:string - Isn't whitespaces preserved by default?

Posted by Wing Yew Poon <wp...@bea.com>.
Well, that's a crucial piece of information that you left out
of your original question - you were using xmlText(XmlOptions),
not xmlText() - and that's why you led others on a wild goose
chase.
This is NOT a bug then. Pretty print by its nature (by design)
does not preserve whitespace. If you need to preserve whitespace
you should not use pretty print. This has been stated multiple
times in this forum.

-----Original Message-----
From: dave [mailto:ceek63@yahoo.com] 
Sent: Tuesday, March 11, 2008 7:31 PM
To: user@xmlbeans.apache.org
Subject: Re: [is this a bug?] Re: xs:string - Isn't whitespaces
preserved by default?


I do setSave** (prettyPrint/PrintIndent) on XmlOptions
object passed to xmlText(). The api doc clearly states
that it'll reformat WhiteSpace chars. 
 Shouldn't these apis honor the contract of underlying
type definitions (like preserve WS chars for xs:string
type,etc) irrespective of these Pretty options? 

 What apis should a user use to preserve these WS
chars yet have pretty print of XML using
xmlText()/XmlOptions.

-D


--- Radu Preotiuc-Pietro <ra...@bea.com> wrote:

> Agreed that the "string" type has whitespace
> preserved. But I don't
> think there is any "general" bug in this area.
> 
> I have done a very very simple test:
> Schema:
> <xs:schema
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <xs:element name="root" type="xs:string"/>
> </xs:schema>
> 
> Instance (test.xml):
> <root>    ABC    </root>
> 
> Code:
> XmlObject doc = XmlObject.Factory.parse(new
> File("test.xml"));
> p(doc.schemaType().toString());
> p(doc.xmlText());
> 
> Output:
> D=root
> <root>    ABC    </root>
> 
> So the spaces are in fact preserved.
> 
> Maybe you are running into a weird edge-case or
> maybe there is some
> detail that you are missing, we would need more
> details to find out
> concretely what the problem is.
> 
> Radu
> 
> On Mon, 2008-03-10 at 00:41 -0700, dave wrote:
> > Isn't it a bug with XmlBeans in that xs:string
> type
> > have whitespace chars removed when written using
> > xmlText/other means? 
> > 
> > As per w3c standard, xs:string should have
> whitespace
> > chars preserved by default. We don't need to
> define
> > 'preserve' facets for this situation.
> > 
> > -D
> > --- Jacob Danner <ja...@gmail.com> wrote:
> > 
> > > How are you generating the XML. I'm not positive
> its
> > > whitespace is
> > > preserved if something like xmlText() is used.
> > > I might try something like an
> xs:normalizedString
> > > and the whitespace=preserve.
> > > -jacobd
> > > 
> > > On Wed, Feb 27, 2008 at 4:57 PM, dave
> > > <ce...@yahoo.com> wrote:
> > > >
> > > >  I have an xs:string type element to hold some
> > > regex
> > > >  expressions. I haven't put any
> > > restrictions/facets for
> > > >  this xs:string type. Isn't by default, it
> should
> > > >  preserve whitespace? Looks like the leading
> and
> > > >  trailing spaces are removed when I generate
> an
> > > XML
> > > >  using XmlBeans apis.
> > > >
> > > >  In general, what is the better XSD data type
> to
> > > hold
> > > >  regex patterns? Is it just xs:string OR
> should I
> > > >  explicitly preserve Whitespace for this
> > > xs:string?



 
________________________________________________________________________
____________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: [is this a bug?] Re: xs:string - Isn't whitespaces preserved by default?

Posted by dave <ce...@yahoo.com>.
I do setSave** (prettyPrint/PrintIndent) on XmlOptions
object passed to xmlText(). The api doc clearly states
that it'll reformat WhiteSpace chars. 
 Shouldn't these apis honor the contract of underlying
type definitions (like preserve WS chars for xs:string
type,etc) irrespective of these Pretty options? 

 What apis should a user use to preserve these WS
chars yet have pretty print of XML using
xmlText()/XmlOptions.

-D


--- Radu Preotiuc-Pietro <ra...@bea.com> wrote:

> Agreed that the "string" type has whitespace
> preserved. But I don't
> think there is any "general" bug in this area.
> 
> I have done a very very simple test:
> Schema:
> <xs:schema
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <xs:element name="root" type="xs:string"/>
> </xs:schema>
> 
> Instance (test.xml):
> <root>    ABC    </root>
> 
> Code:
> XmlObject doc = XmlObject.Factory.parse(new
> File("test.xml"));
> p(doc.schemaType().toString());
> p(doc.xmlText());
> 
> Output:
> D=root
> <root>    ABC    </root>
> 
> So the spaces are in fact preserved.
> 
> Maybe you are running into a weird edge-case or
> maybe there is some
> detail that you are missing, we would need more
> details to find out
> concretely what the problem is.
> 
> Radu
> 
> On Mon, 2008-03-10 at 00:41 -0700, dave wrote:
> > Isn't it a bug with XmlBeans in that xs:string
> type
> > have whitespace chars removed when written using
> > xmlText/other means? 
> > 
> > As per w3c standard, xs:string should have
> whitespace
> > chars preserved by default. We don't need to
> define
> > 'preserve' facets for this situation.
> > 
> > -D
> > --- Jacob Danner <ja...@gmail.com> wrote:
> > 
> > > How are you generating the XML. I'm not positive
> its
> > > whitespace is
> > > preserved if something like xmlText() is used.
> > > I might try something like an
> xs:normalizedString
> > > and the whitespace=preserve.
> > > -jacobd
> > > 
> > > On Wed, Feb 27, 2008 at 4:57 PM, dave
> > > <ce...@yahoo.com> wrote:
> > > >
> > > >  I have an xs:string type element to hold some
> > > regex
> > > >  expressions. I haven't put any
> > > restrictions/facets for
> > > >  this xs:string type. Isn't by default, it
> should
> > > >  preserve whitespace? Looks like the leading
> and
> > > >  trailing spaces are removed when I generate
> an
> > > XML
> > > >  using XmlBeans apis.
> > > >
> > > >  In general, what is the better XSD data type
> to
> > > hold
> > > >  regex patterns? Is it just xs:string OR
> should I
> > > >  explicitly preserve Whitespace for this
> > > xs:string?



      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: [is this a bug?] Re: xs:string - Isn't whitespaces preserved by default?

Posted by Radu Preotiuc-Pietro <ra...@bea.com>.
Agreed that the "string" type has whitespace preserved. But I don't
think there is any "general" bug in this area.

I have done a very very simple test:
Schema:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root" type="xs:string"/>
</xs:schema>

Instance (test.xml):
<root>    ABC    </root>

Code:
XmlObject doc = XmlObject.Factory.parse(new File("test.xml"));
p(doc.schemaType().toString());
p(doc.xmlText());

Output:
D=root
<root>    ABC    </root>

So the spaces are in fact preserved.

Maybe you are running into a weird edge-case or maybe there is some
detail that you are missing, we would need more details to find out
concretely what the problem is.

Radu

On Mon, 2008-03-10 at 00:41 -0700, dave wrote:
> Isn't it a bug with XmlBeans in that xs:string type
> have whitespace chars removed when written using
> xmlText/other means? 
> 
> As per w3c standard, xs:string should have whitespace
> chars preserved by default. We don't need to define
> 'preserve' facets for this situation.
> 
> -D
> --- Jacob Danner <ja...@gmail.com> wrote:
> 
> > How are you generating the XML. I'm not positive its
> > whitespace is
> > preserved if something like xmlText() is used.
> > I might try something like an xs:normalizedString
> > and the whitespace=preserve.
> > -jacobd
> > 
> > On Wed, Feb 27, 2008 at 4:57 PM, dave
> > <ce...@yahoo.com> wrote:
> > >
> > >  I have an xs:string type element to hold some
> > regex
> > >  expressions. I haven't put any
> > restrictions/facets for
> > >  this xs:string type. Isn't by default, it should
> > >  preserve whitespace? Looks like the leading and
> > >  trailing spaces are removed when I generate an
> > XML
> > >  using XmlBeans apis.
> > >
> > >  In general, what is the better XSD data type to
> > hold
> > >  regex patterns? Is it just xs:string OR should I
> > >  explicitly preserve Whitespace for this
> > xs:string?
> > >
> > >
> > >      
> >
> ____________________________________________________________________________________
> > >  Be a better friend, newshound, and
> > >  know-it-all with Yahoo! Mobile.  Try it now. 
> >
> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
> > >
> > >
> > > 
> >
> ---------------------------------------------------------------------
> > >  To unsubscribe, e-mail:
> > user-unsubscribe@xmlbeans.apache.org
> > >  For additional commands, e-mail:
> > user-help@xmlbeans.apache.org
> > >
> > >
> > 
> > 
> > 
> > -- 
> > I'm competing in a Half-Ironman distance triathlon
> > to raise money for
> > the fight against cancer!
> > Please help support my efforts by going to:
> > http://www.active.com/donate/tntwaak/jacobd
> > 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail:
> > user-help@xmlbeans.apache.org
> > 
> > 
> 
> 
> 
>       ____________________________________________________________________________________
> Be a better friend, newshound, and 
> know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 

Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org