You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Frank Z <fj...@yahoo.com> on 2008/10/06 21:13:46 UTC

default namespace and empty namespace (xmlns="") during serialization.

Apologize in advance if this has been asked before. I am still a little confused as to how to serialize a document with basic namespace handling

When I use the default option (ie. none), serializing my document yields
the following

<?xml version="1.0" encoding="UTF-8"?>
<cus:CustomErrors xmlns:cus="http://customerror.xml.acmeweb.com">
  <WarningFlag>false</WarningFlag>
  <ErrorFlag>true</ErrorFlag>
  <FatalErrorFlag>false</FatalErrorFlag>
  <ErrorCount>2</ErrorCount>

If I turn call xmlOptions.setUseDefaultNamespace() prior to serializing, I get


<CustomErrors xmlns="http://customerror.xml.acmeweb.com">
  <WarningFlag xmlns="">false</WarningFlag>
  <ErrorFlag xmlns="">true</ErrorFlag>
  <FatalErrorFlag xmlns="">false</FatalErrorFlag>
  <ErrorCount xmlns="">2</ErrorCount>
...

This is probably worse because most of our customers simply don't know how to handle xmlns="" in the child element.

Is there a simple way to serialize my document and get somethign like this (ie. without any prefix?)

<?xml version="1.0" encoding="UTF-8"?>
<CustomErrors xmlns:"http://customerror.xml.acmeweb.com">
  <WarningFlag>false</WarningFlag>
  <ErrorFlag>true</ErrorFlag>
  <FatalErrorFlag>false</FatalErrorFlag>
  <ErrorCount>2</ErrorCount>

I've searched FAQ and googled but found no simple answers for this question.

Thanks in advance
Frank.




      

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


Re: default namespace and empty namespace (xmlns="") during serialization.

Posted by Frank Z <fj...@yahoo.com>.
Please ignore. I found the solution, albeit a little unclear

<xs:schema

     elementFormDefault="qualified"

	targetNamespace="customerror.xml.acmeweb.com"	xmlns:tns="customerror.xml.acmeweb.com"	xmlns:xs="http://www.w3.org/2001/XMLSchema">


By adding the 'elementFormDefault="qualified"' into my XSD 
and calling xmlOptions.setUseDefaultNamespace();  prior to saving, I am able to get what I want.  Hopefully this will help someone else in the future.







--- On Mon, 10/6/08, Frank Z <fj...@yahoo.com> wrote:

> From: Frank Z <fj...@yahoo.com>
> Subject: default namespace and empty namespace (xmlns="") during serialization.
> To: user@xmlbeans.apache.org
> Date: Monday, October 6, 2008, 12:13 PM
> Apologize in advance if this has been asked before. I am
> still a little confused as to how to serialize a document
> with basic namespace handling
> 
> When I use the default option (ie. none), serializing my
> document yields
> the following
> 
> <?xml version="1.0"
> encoding="UTF-8"?>
> <cus:CustomErrors
> xmlns:cus="http://customerror.xml.acmeweb.com">
>   <WarningFlag>false</WarningFlag>
>   <ErrorFlag>true</ErrorFlag>
>   <FatalErrorFlag>false</FatalErrorFlag>
>   <ErrorCount>2</ErrorCount>
> 
> If I turn call xmlOptions.setUseDefaultNamespace() prior to
> serializing, I get
> 
> 
> <CustomErrors
> xmlns="http://customerror.xml.acmeweb.com">
>   <WarningFlag
> xmlns="">false</WarningFlag>
>   <ErrorFlag
> xmlns="">true</ErrorFlag>
>   <FatalErrorFlag
> xmlns="">false</FatalErrorFlag>
>   <ErrorCount xmlns="">2</ErrorCount>
> ...
> 
> This is probably worse because most of our customers simply
> don't know how to handle xmlns="" in the child
> element.
> 
> Is there a simple way to serialize my document and get
> somethign like this (ie. without any prefix?)
> 
> <?xml version="1.0"
> encoding="UTF-8"?>
> <CustomErrors
> xmlns:"http://customerror.xml.acmeweb.com">
>   <WarningFlag>false</WarningFlag>
>   <ErrorFlag>true</ErrorFlag>
>   <FatalErrorFlag>false</FatalErrorFlag>
>   <ErrorCount>2</ErrorCount>
> 
> I've searched FAQ and googled but found no simple
> answers for this question.
> 
> Thanks in advance
> Frank.
> 
> 
> 
> 
>       
> 
> ---------------------------------------------------------------------
> 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