Re: [xml] [PATCH] Correct a small typo

2016-04-10 Thread Daniel Veillard
On Sun, Apr 03, 2016 at 05:25:57AM +0300, Shlomi Fish wrote:
> The attached patch corrects a small typo - "duplcates" is a misspelling.
> 
> Regards,
> 
>   Shlomi Fish

  Sure, pushed,

   thanks,

Daniel

> -- 
> -
> Shlomi Fish   http://www.shlomifish.org/
> 
> Chuck Norris is *not* going to miss Anna Kendrick when she’s gone.
> — http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/
> 
> Please reply to list if it's a mailing list post - http://shlom.in/reply .

> >From c9a0d63767d55da0f6a5fb8a6c7a05f137944e64 Mon Sep 17 00:00:00 2001
> From: Shlomi Fish 
> Date: Sun, 3 Apr 2016 05:14:44 +0300
> Subject: [PATCH] Correct a typo.
> 
> ---
>  xpath.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xpath.c b/xpath.c
> index 935fcff..512bbf4 100644
> --- a/xpath.c
> +++ b/xpath.c
> @@ -3706,7 +3706,7 @@ xmlXPathNodeSetAdd(xmlNodeSetPtr cur, xmlNodePtr val) {
>  
>  /* @@ with_ns to check whether namespace nodes should be looked at @@ */
>  /*
> - * prevent duplcates
> + * prevent duplicates
>   */
>  for (i = 0;i < cur->nodeNr;i++)
>  if (cur->nodeTab[i] == val) return(0);
> -- 
> 2.7.4
> 

> ___
> xml mailing list, project page  http://xmlsoft.org/
> xml@gnome.org
> https://mail.gnome.org/mailman/listinfo/xml


-- 
Daniel Veillard  | Open Source and Standards, Red Hat
veill...@redhat.com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | virtualization library  http://libvirt.org/
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] default values from schema

2016-04-10 Thread Daniel Veillard
On Sat, Mar 26, 2016 at 09:48:59PM +0100, Fabian Wein wrote:
> Hello to the list,
> 
> I know I have a FAQ but I cannot manage it by myself :(
> 
> I have a xsd schema and need to validate *and* parse a xml file making use
> of the default values from the schema. 
> 
> In the end I need it in C++ but I guess it helps to have it first in Python?!
> 
> My minimalistic example is based on 
> http://www.w3schools.com/xml/schema_howto.asp
> extended by attributes, one with default -> see attachment.
> 
> Validating works nicely :) Any error in the xml is detected or ret=0 if the 
> file is ok.
> 
> doc = libxml2.parseFile(„node.xml“)
> s = libxml2.schemaNewParserCtxt(„node.xsd“)
> sp = s.schemaParse()
> ct = sp.schemaNewValidCtxt()  
> ret = ct.schemaValidateDoc(doc)
> 
> But I have no idea on how to get the populated data from this (only from doc).
> 
> Then I tried to extend the reader example:
> 
> def streamFile(filename):
> reader = libxml2.newTextReaderFilename(filename)
> s = libxml2.schemaNewParserCtxt(‚node.xsd‘)
> sp = s.schemaParse()
> ct = sp.schemaNewValidCtxt()
> ct.schemaSetValidOptions(libxml2.XML_SCHEMA_VAL_VC_I_CREATE)
> ct.SchemaValidateCtxt(reader, libxml2.XML_SCHEMA_VAL_VC_I_CREATE)
> 
> reader.SetSchema(ct)
> reader.SetParserProp(libxml2.PARSER_DEFAULTATTRS, 1)
> ret = reader.Read()
> while ret == 1:
> processNode(reader)
> ret = reader.Read()
> 
> However, with the reader api the root element is not recognized and the 
> default attribute is not set:
> 
> Element ‚{http://www.w3schools.com}note‘: No matching global declaration 
> available for the validation root.
> 
> As the schema is validated properly in the first code I believe the schema is 
> ok.
> 
> So my questions are:
> * Which api shall I use to make use of the default values?

  I don't think the toolkit has the support in XML schemas to populate default
values back in the tree.

> * Shall I try in C instead of Python?
> * Is there a link which helps me? I spent two days googling without success :(

  and that explain why,

> Thanks a lot!

   sorry,

Daniel
> Fabian
> 
> 
> 


> 
> 
> 


> ___
> xml mailing list, project page  http://xmlsoft.org/
> xml@gnome.org
> https://mail.gnome.org/mailman/listinfo/xml


-- 
Daniel Veillard  | Open Source and Standards, Red Hat
veill...@redhat.com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | virtualization library  http://libvirt.org/
___
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml