You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Ole Matzura <ol...@eviware.com> on 2007/08/20 09:42:19 UTC

remove unused namespaces?

Hi!

Is there any way to remove unused namespaces from an XmlObject when it 
is being saved? My situation is the following:

1) Parse a document with a large number of namespaces
2) Change the content of the document so that many of the namespaces are 
not used anymore
3) Save the document

Now I still get a long list of xmlns:... definitions in the document 
element although there is no content that actually uses them..

Thanks for any tips!

regards,

/Ole
eviware.com


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


Re: remove unused namespaces?

Posted by Ole Matzura <ol...@eviware.com>.
Hi,

exactly, I was using parse(String).. what is the recommended way to 
parse to get this option working?

Anyway, I used the XmlCursor API as you suggested and it works just fine!

thanks again for answering,

regards,

/Ole
eviware.com

Jacob Danner wrote:
> How were you building your instance. I know there are certain cases
> where those options will not work (like parse(String)) and those are
> known and working as designed. You may want to search the mailing
> lists to see if this is one of those cases.
> Otherwise, the other option might be to write something up using the
> xml cursor APIs if you are going to be doing this a lot
> -Jacobd
>
> On 8/20/07, Ole Matzura <ol...@eviware.com> wrote:
>   
>> Hi Jacob,
>>
>> Thanks for answering.. unfortunately this didn't work.. I tried a number
>> of combinations with different XmlOptions etc without any luck..  Should
>> I file a bug report somewhere?
>>
>> anyhow, I worked around it for now by removing those not used manually..
>>
>> best regards,
>>
>> /Ole
>> eviware.com
>>
>> Jacob Danner wrote:
>>     
>>> Hi Ole,
>>> You should try the XmlOptions method(s):
>>>
>>>  XmlOptions   setSaveAggressiveNamespaces()
>>>           Causes the saver to reduce the number of namespace prefix
>>> declarations.
>>>
>>> Depending on how you are building your document this should work.
>>> Hope this helps,
>>> -Jacob Danner
>>>
>>>
>>> On 8/20/07, Ole Matzura <ol...@eviware.com> wrote:
>>>
>>>       
>>>> Hi!
>>>>
>>>> Is there any way to remove unused namespaces from an XmlObject when it
>>>> is being saved? My situation is the following:
>>>>
>>>> 1) Parse a document with a large number of namespaces
>>>> 2) Change the content of the document so that many of the namespaces are
>>>> not used anymore
>>>> 3) Save the document
>>>>
>>>> Now I still get a long list of xmlns:... definitions in the document
>>>> element although there is no content that actually uses them..
>>>>
>>>> Thanks for any tips!
>>>>
>>>> regards,
>>>>
>>>> /Ole
>>>> eviware.com
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
>>>> For additional commands, e-mail: user-help@xmlbeans.apache.org
>>>>
>>>>
>>>>
>>>>         
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
>>> For additional commands, e-mail: user-help@xmlbeans.apache.org
>>>
>>>
>>>
>>>
>>>
>>>       
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
>> For additional commands, e-mail: user-help@xmlbeans.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>
>
>
>   



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


Re: remove unused namespaces?

Posted by Jacob Danner <ja...@gmail.com>.
How were you building your instance. I know there are certain cases
where those options will not work (like parse(String)) and those are
known and working as designed. You may want to search the mailing
lists to see if this is one of those cases.
Otherwise, the other option might be to write something up using the
xml cursor APIs if you are going to be doing this a lot
-Jacobd

On 8/20/07, Ole Matzura <ol...@eviware.com> wrote:
> Hi Jacob,
>
> Thanks for answering.. unfortunately this didn't work.. I tried a number
> of combinations with different XmlOptions etc without any luck..  Should
> I file a bug report somewhere?
>
> anyhow, I worked around it for now by removing those not used manually..
>
> best regards,
>
> /Ole
> eviware.com
>
> Jacob Danner wrote:
> > Hi Ole,
> > You should try the XmlOptions method(s):
> >
> >  XmlOptions   setSaveAggressiveNamespaces()
> >           Causes the saver to reduce the number of namespace prefix
> > declarations.
> >
> > Depending on how you are building your document this should work.
> > Hope this helps,
> > -Jacob Danner
> >
> >
> > On 8/20/07, Ole Matzura <ol...@eviware.com> wrote:
> >
> >> Hi!
> >>
> >> Is there any way to remove unused namespaces from an XmlObject when it
> >> is being saved? My situation is the following:
> >>
> >> 1) Parse a document with a large number of namespaces
> >> 2) Change the content of the document so that many of the namespaces are
> >> not used anymore
> >> 3) Save the document
> >>
> >> Now I still get a long list of xmlns:... definitions in the document
> >> element although there is no content that actually uses them..
> >>
> >> Thanks for any tips!
> >>
> >> regards,
> >>
> >> /Ole
> >> eviware.com
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> >> For additional commands, e-mail: user-help@xmlbeans.apache.org
> >>
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> >
> >
> >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>

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


Re: remove unused namespaces?

Posted by Ole Matzura <ol...@eviware.com>.
Hi Jacob,

Thanks for answering.. unfortunately this didn't work.. I tried a number 
of combinations with different XmlOptions etc without any luck..  Should 
I file a bug report somewhere?

anyhow, I worked around it for now by removing those not used manually..

best regards,

/Ole
eviware.com

Jacob Danner wrote:
> Hi Ole,
> You should try the XmlOptions method(s):
>
>  XmlOptions 	setSaveAggressiveNamespaces()
>           Causes the saver to reduce the number of namespace prefix
> declarations.
>
> Depending on how you are building your document this should work.
> Hope this helps,
> -Jacob Danner
>
>
> On 8/20/07, Ole Matzura <ol...@eviware.com> wrote:
>   
>> Hi!
>>
>> Is there any way to remove unused namespaces from an XmlObject when it
>> is being saved? My situation is the following:
>>
>> 1) Parse a document with a large number of namespaces
>> 2) Change the content of the document so that many of the namespaces are
>> not used anymore
>> 3) Save the document
>>
>> Now I still get a long list of xmlns:... definitions in the document
>> element although there is no content that actually uses them..
>>
>> Thanks for any tips!
>>
>> regards,
>>
>> /Ole
>> eviware.com
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
>> For additional commands, e-mail: user-help@xmlbeans.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>
>
>
>   



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


Re: remove unused namespaces?

Posted by Jacob Danner <ja...@gmail.com>.
Hi Ole,
You should try the XmlOptions method(s):

 XmlOptions 	setSaveAggressiveNamespaces()
          Causes the saver to reduce the number of namespace prefix
declarations.

Depending on how you are building your document this should work.
Hope this helps,
-Jacob Danner


On 8/20/07, Ole Matzura <ol...@eviware.com> wrote:
> Hi!
>
> Is there any way to remove unused namespaces from an XmlObject when it
> is being saved? My situation is the following:
>
> 1) Parse a document with a large number of namespaces
> 2) Change the content of the document so that many of the namespaces are
> not used anymore
> 3) Save the document
>
> Now I still get a long list of xmlns:... definitions in the document
> element although there is no content that actually uses them..
>
> Thanks for any tips!
>
> regards,
>
> /Ole
> eviware.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>

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