On 15/10/2007, Alex Wibowo <[EMAIL PROTECTED]> wrote:
> Hi Marteen,
>
>
> I havent found any 'good' solution to this yet. The best solution I have
> found so far, is to either:
>
> 1. Insert the attribute 'xmlns'. But as pointed by Andrew, we are inserting
> attribute with name 'xmlns', and not a namespace. This is fine for me,
> since I dont need the XmlObject after this modification (I just need to spit
> the result back as string). Example:
>
> -------------------------------------
> XmlCursor cursor = xmlObject.newCursor();
> // Cursor at STARTDOC
>
> cursor.toNextToken();
> // Cursor at START
>
> cursor.toNextToken();
> // Cursor after START
>
> cursor.insertAttributeWithValue("xmlns","http://www.namespace.com ");
> -------------------------------------
>
>
>
> 2. Insert the QName (again, as suggested by Andrew). Example:
>
> -------------------------------------
> XmlCursor cursor = xmlObject.newCursor();
> // Cursor at STARTDOC
>
> cursor.toNextToken();
> // Cursor at START
>
> cursor.setName(new
> QName("http://www.namespace.com",cursor.getName().getLocalPart(),""));
> -------------------------------------
Although option 1 appears to work it of course the wrong route to take
because you won't be able to generate a namespace with a prefix, and
as you say it generates the wrong internal objects.
It's much safer whenever you deal with XML names to use QNames.
--
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]