List Info

Thread: Inserting node using xpath and schema




Inserting node using xpath and schema
user name
2006-08-18 16:40:08
I'm fairly new to xmllib2 and could not find answers to my
questions
below by searching the FAQ and list archives. I'm trying to
determine
how I can use xmllib2 to accomplish the following:

- I have a parsed XML document in memory 
- I have multiple schemas for the document (a base schema
and
extensions)
- I have an Xpath element expression and an element value

I want to be able to add the new element and value to the
document based
on the Xpath expression and the schemas. The schema contains
sequences
so the Xpath element has to inserted as a child node in
between existing
siblings.

I can add a child node but its always after all of the
existing
children.

Are there APIs that allow me to insert a node in between
existing
sibling nodes?

Is there a way to use a schema to tell libxml2 to insert a
node as a
child of a parent and the schema is used to determine the
proper
location of the node amongst the existing children?

Thanks in advance,

Joe
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Inserting node using xpath and schema
user name
2006-08-18 22:18:45
On Fri, Aug 18, 2006 at 12:40:08PM -0400, Kreidler
Joseph-QA1818 wrote:
> I'm fairly new to xmllib2 and could not find answers
to my questions
> below by searching the FAQ and list archives. I'm
trying to determine
> how I can use xmllib2 to accomplish the following:
> 
> - I have a parsed XML document in memory 
> - I have multiple schemas for the document (a base
schema and
> extensions)
> - I have an Xpath element expression and an element
value
> 
> I want to be able to add the new element and value to
the document based
> on the Xpath expression and the schemas. The schema
contains sequences
> so the Xpath element has to inserted as a child node in
between existing
> siblings.
> 
> I can add a child node but its always after all of the
existing
> children.
> 
> Are there APIs that allow me to insert a node in
between existing
> sibling nodes?

  create the node, then use xmlAddPrevSibling or
xmlAddNextSibling 

> Is there a way to use a schema to tell libxml2 to
insert a node as a
> child of a parent and the schema is used to determine
the proper
> location of the node amongst the existing children?

  no

Daniel

-- 
Red Hat Virtualization group http://redhat.com/v
irtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillardredhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ |
Rpmfind RPM search engine  http://rpmfind.net/
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Inserting node using xpath and schema
user name
2006-08-22 13:22:11
Resending since I did not receive any replies. Does anyone
know the
answers to the questions below???

Thanks in advance,

Joe


-----Original Message-----
From: xml-bouncesgnome.org [mailtoml-bo
uncesgnome.org] On Behalf Of
Kreidler Joseph-QA1818
Sent: Friday, August 18, 2006 11:40 AM
To: xmlgnome.org
Subject: [xml] Inserting node using xpath and schema

I'm fairly new to libxml2 and could not find answers to my
questions
below by searching the FAQ and list archives. I'm trying to
determine
how I can use libxml2 to accomplish the following:

- I have a parsed XML document in memory 
- I have multiple schemas for the document (a base schema
and
extensions)
- I have an Xpath element expression and an element value

I want to be able to add the new element and value to the
document based
on the Xpath expression and the schemas. The schema contains
sequences
so the Xpath element has to inserted as a child node in
between existing
siblings.

I can add a child node but its always after all of the
existing
children.

Are there APIs that allow me to insert a node in between
existing
sibling nodes?

Is there a way to use a schema to tell libxml2 to insert a
node as a
child of a parent and the schema is used to determine the
proper
location of the node amongst the existing children?

Thanks in advance,

Joe
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Inserting node using xpath and schema
user name
2006-08-22 14:11:56
Hi Joe,

Did you look at the site http://xmlsoft.org ?

It contains developer documentation, including samples that
should  
help you to proceed.
(it worked for me)

> I'm fairly new to libxml2 and could not find answers
to my questions
> below by searching the FAQ and list archives. I'm
trying to determine
> how I can use libxml2 to accomplish the following:
>
> - I have a parsed XML document in memory
> - I have multiple schemas for the document (a base
schema and
> extensions)
> - I have an Xpath element expression and an element
value

See http://xmlsoft.org/docs.
html

> I want to be able to add the new element and value to
the document  
> based
> on the Xpath expression and the schemas. The schema
contains sequences
> so the Xpath element has to inserted as a child node in
between  
> existing
> siblings.
>

This sounds pretty straight forward, but I must say that it
is not to  
clear to me what you actually want todo. For xpath coding
see http:// 
xmlsoft.org/html/libxml-xpath.html

> I can add a child node but its always after all of the
existing
> children.
>
> Are there APIs that allow me to insert a node in
between existing
> sibling nodes?

See http://xmlso
ft.org/html/libxml-tree.html

>
> Is there a way to use a schema to tell libxml2 to
insert a node as a
> child of a parent and the schema is used to determine
the proper
> location of the node amongst the existing children?
>
Don't know, I didn't do too much with the schema parts of
the code.  
This sounds as a piece of custom (your own) logic but I
could be wrong.

If you wonder how you can use these APIs, see http://xmlsoft.org/ 
examples/index.html

> Thanks in advance,
>
> Joe
It would probably help to post more specific questions in
order to  
get an answer.


Kind Regards,

Olger



_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Inserting node using xpath and schema
user name
2006-08-22 14:33:21
On Tue, Aug 22, 2006 at 09:22:11AM -0400, Kreidler
Joseph-QA1818 wrote:
> Resending since I did not receive any replies. Does
anyone know the
> answers to the questions below???

  I did reply ... on the mailing-list, 5hours and a half
after your mail
hit the list !
  http://mail.gnome.org/archives/xml/2006-August/msg00
075.html

Daniel

    

-- 
Red Hat Virtualization group http://redhat.com/v
irtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillardredhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ |
Rpmfind RPM search engine  http://rpmfind.net/
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )