You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Christian Schweers <cs...@web.de> on 2006/04/30 01:57:02 UTC
Move xml content
Hi all,
how can i move Xml content?
Here is my xml document sample.
<content>
<Media>
<Title>Mov1</Title>
<MediaType>DVD</MediaType>
</Media>
<Media>
<Title>Mov2</Title>
<MediaType>DVD</MediaType>
</Media>
<Media>
<Title>Mov3</Title>
<MediaType>DVD</MediaType>
</Media>
<Media>
<Title>Mov4</Title>
<MediaType>DVD</MediaType>
</Media>
</content>
The challenge is to move the "Media" Tag with Title Mov4 to position one!
Looks like this:
<content>
<Media>
<Title>Mov4</Title>
<MediaType>DVD</MediaType>
</Media>
<Media>
<Title>Mov1</Title>
<MediaType>DVD</MediaType>
</Media>
<Media>
<Title>Mov2</Title>
<MediaType>DVD</MediaType>
</Media>
<Media>
<Title>Mov3</Title>
<MediaType>DVD</MediaType>
</Media>
</content>
How can i do this?
The following doesn't work :(
XmlCursor sourceCursor = xml.newCursor();
searchPath = "Media[Title='Mov4']";
sourceCursor.selectPath(searchPath);
XmlCursor targetCursor = xml.newCursor();
searchPath = "Media[Title='Mov1']";
targetCursor.selectPath(searchPath);
sourceCursor.moveXmlContents(targetCursor) ---> Error: Can't insert
before the start of the document.
sourceCursorCursor.moveXml(targetCursor) ---> Error: Can't
move/copy/insert a whole document.
I hope someone can help me.
Thanks in advance.
Christian
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org
Re: Move xml content
Posted by Christian Schweers <cs...@web.de>.
Hello,
thanks for the reply but it doesn't work :-(
Yet another idea?
Christian
Ben Jelloul Marouane schrieb:
> Hi
> I m no a pro but probably at the line:
> sourceCursor.moveXmlContents(targetCursor);
> your sourceCursor is one tag to bottom so you have to to something like:
> sourceCursor.toParent();
> sourceCursor.moveXmlContents(targetCursor);
>
> I hope that will help
> Marouane
>
>
> On Sun, 2006-04-30 at 01:57, Christian Schweers wrote:
>
>> Hi all,
>>
>> how can i move Xml content?
>>
>> Here is my xml document sample.
>>
>> <content>
>> <Media>
>> <Title>Mov1</Title>
>> <MediaType>DVD</MediaType>
>> </Media>
>> <Media>
>> <Title>Mov2</Title>
>> <MediaType>DVD</MediaType>
>> </Media>
>> <Media>
>> <Title>Mov3</Title>
>> <MediaType>DVD</MediaType>
>> </Media>
>> <Media>
>> <Title>Mov4</Title>
>> <MediaType>DVD</MediaType>
>> </Media>
>> </content>
>>
>> The challenge is to move the "Media" Tag with Title Mov4 to position one!
>>
>> Looks like this:
>>
>> <content>
>> <Media>
>> <Title>Mov4</Title>
>> <MediaType>DVD</MediaType>
>> </Media>
>> <Media>
>> <Title>Mov1</Title>
>> <MediaType>DVD</MediaType>
>> </Media>
>> <Media>
>> <Title>Mov2</Title>
>> <MediaType>DVD</MediaType>
>> </Media>
>> <Media>
>> <Title>Mov3</Title>
>> <MediaType>DVD</MediaType>
>> </Media>
>> </content>
>>
>> How can i do this?
>>
>> The following doesn't work :(
>>
>> XmlCursor sourceCursor = xml.newCursor();
>> searchPath = "Media[Title='Mov4']";
>> sourceCursor.selectPath(searchPath);
>>
>> XmlCursor targetCursor = xml.newCursor();
>> searchPath = "Media[Title='Mov1']";
>> targetCursor.selectPath(searchPath);
>>
>> sourceCursor.moveXmlContents(targetCursor) ---> Error: Can't insert
>> before the start of the document.
>> sourceCursorCursor.moveXml(targetCursor) ---> Error: Can't
>> move/copy/insert a whole document.
>>
>> I hope someone can help me.
>>
>> Thanks in advance.
>>
>> Christian
>>
>>
>> ---------------------------------------------------------------------
>> 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
How to get information within Node?
Posted by johnli121 <jo...@gmail.com>.
Hi,
When parsing a DOM node, many related information are lost. Is it the
behavior of xmlbeans?
Please check point 1, 2 and 3.
public void parseNode(org.w3c.dom.Node node)
{
XmlObject obj = XmlObject.Factory.parse(node);
XmlCursor cursor = obj.newCursor();
//1.) The uri is NULL. The document info with node is lost.
String uri = cursor.documentProperties().getSourceName();
//2.) qname is NULL.
QName qname = cursor.getName();
//3.) Have to patch it like this.
cursor.toNextToken();
//Now qname is OK.
qname = cursor.getName();
}
Thanks,
John
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org
Re: Move xml content
Posted by Ben Jelloul Marouane <m....@nki.nl>.
Hi
I m no a pro but probably at the line:
sourceCursor.moveXmlContents(targetCursor);
your sourceCursor is one tag to bottom so you have to to something like:
sourceCursor.toParent();
sourceCursor.moveXmlContents(targetCursor);
I hope that will help
Marouane
On Sun, 2006-04-30 at 01:57, Christian Schweers wrote:
> Hi all,
>
> how can i move Xml content?
>
> Here is my xml document sample.
>
> <content>
> <Media>
> <Title>Mov1</Title>
> <MediaType>DVD</MediaType>
> </Media>
> <Media>
> <Title>Mov2</Title>
> <MediaType>DVD</MediaType>
> </Media>
> <Media>
> <Title>Mov3</Title>
> <MediaType>DVD</MediaType>
> </Media>
> <Media>
> <Title>Mov4</Title>
> <MediaType>DVD</MediaType>
> </Media>
> </content>
>
> The challenge is to move the "Media" Tag with Title Mov4 to position one!
>
> Looks like this:
>
> <content>
> <Media>
> <Title>Mov4</Title>
> <MediaType>DVD</MediaType>
> </Media>
> <Media>
> <Title>Mov1</Title>
> <MediaType>DVD</MediaType>
> </Media>
> <Media>
> <Title>Mov2</Title>
> <MediaType>DVD</MediaType>
> </Media>
> <Media>
> <Title>Mov3</Title>
> <MediaType>DVD</MediaType>
> </Media>
> </content>
>
> How can i do this?
>
> The following doesn't work :(
>
> XmlCursor sourceCursor = xml.newCursor();
> searchPath = "Media[Title='Mov4']";
> sourceCursor.selectPath(searchPath);
>
> XmlCursor targetCursor = xml.newCursor();
> searchPath = "Media[Title='Mov1']";
> targetCursor.selectPath(searchPath);
>
> sourceCursor.moveXmlContents(targetCursor) ---> Error: Can't insert
> before the start of the document.
> sourceCursorCursor.moveXml(targetCursor) ---> Error: Can't
> move/copy/insert a whole document.
>
> I hope someone can help me.
>
> Thanks in advance.
>
> Christian
>
>
> ---------------------------------------------------------------------
> 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