Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
92bfadef
Commit
92bfadef
authored
Nov 22, 2010
by
Adam Martinson
Committed by
Alexandre Julliard
Nov 24, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msxml3: Add schema parse/validate error callbacks.
parent
6ee2231d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
53 deletions
+93
-53
schema.c
dlls/msxml3/schema.c
+93
-53
No files found.
dlls/msxml3/schema.c
View file @
92bfadef
...
...
@@ -214,6 +214,87 @@ static const BYTE hash_assoc_values[] =
116
,
116
,
116
,
116
,
116
,
116
};
static
void
LIBXML2_LOG_CALLBACK
parser_error
(
void
*
ctx
,
char
const
*
msg
,
...)
{
va_list
ap
;
va_start
(
ap
,
msg
);
LIBXML2_CALLBACK_ERR
(
Schema_parse
,
msg
,
ap
);
va_end
(
ap
);
}
static
void
LIBXML2_LOG_CALLBACK
parser_warning
(
void
*
ctx
,
char
const
*
msg
,
...)
{
va_list
ap
;
va_start
(
ap
,
msg
);
LIBXML2_CALLBACK_WARN
(
Schema_parse
,
msg
,
ap
);
va_end
(
ap
);
}
#ifdef HAVE_XMLSCHEMASSETPARSERSTRUCTUREDERRORS
static
void
parser_serror
(
void
*
ctx
,
xmlErrorPtr
err
)
{
LIBXML2_CALLBACK_SERROR
(
Schema_parse
,
err
);
}
#endif
static
inline
xmlSchemaPtr
Schema_parse
(
xmlSchemaParserCtxtPtr
spctx
)
{
TRACE
(
"(%p)
\n
"
,
spctx
);
xmlSchemaSetParserErrors
(
spctx
,
parser_error
,
parser_warning
,
NULL
);
#ifdef HAVE_XMLSCHEMASSETPARSERSTRUCTUREDERRORS
xmlSchemaSetParserStructuredErrors
(
spctx
,
parser_serror
,
NULL
);
#endif
return
xmlSchemaParse
(
spctx
);
}
static
void
LIBXML2_LOG_CALLBACK
validate_error
(
void
*
ctx
,
char
const
*
msg
,
...)
{
va_list
ap
;
va_start
(
ap
,
msg
);
LIBXML2_CALLBACK_ERR
(
Schema_validate_tree
,
msg
,
ap
);
va_end
(
ap
);
}
static
void
LIBXML2_LOG_CALLBACK
validate_warning
(
void
*
ctx
,
char
const
*
msg
,
...)
{
va_list
ap
;
va_start
(
ap
,
msg
);
LIBXML2_CALLBACK_WARN
(
Schema_validate_tree
,
msg
,
ap
);
va_end
(
ap
);
}
#ifdef HAVE_XMLSCHEMASSETVALIDSTRUCTUREDERRORS
static
void
validate_serror
(
void
*
ctx
,
xmlErrorPtr
err
)
{
LIBXML2_CALLBACK_SERROR
(
Schema_validate_tree
,
err
);
}
#endif
static
inline
HRESULT
Schema_validate_tree
(
xmlSchemaPtr
schema
,
xmlNodePtr
tree
)
{
xmlSchemaValidCtxtPtr
svctx
;
int
err
;
TRACE
(
"(%p, %p)
\n
"
,
schema
,
tree
);
/* TODO: if validateOnLoad property is false,
* we probably need to validate the schema here. */
svctx
=
xmlSchemaNewValidCtxt
(
schema
);
xmlSchemaSetValidErrors
(
svctx
,
validate_error
,
validate_warning
,
NULL
);
#ifdef HAVE_XMLSCHEMASSETVALIDSTRUCTUREDERRORS
xmlSchemaSetValidStructuredErrors
(
svctx
,
validate_serror
,
NULL
);
#endif
if
(
tree
->
type
==
XML_DOCUMENT_NODE
)
err
=
xmlSchemaValidateDoc
(
svctx
,
(
xmlDocPtr
)
tree
);
else
err
=
xmlSchemaValidateOneElement
(
svctx
,
tree
);
xmlSchemaFreeValidCtxt
(
svctx
);
return
err
?
S_FALSE
:
S_OK
;
}
static
DWORD
dt_hash
(
xmlChar
const
*
str
,
int
len
/* calculated if -1 */
)
{
DWORD
hval
=
(
len
==
-
1
)
?
xmlStrlen
(
str
)
:
len
;
...
...
@@ -491,14 +572,16 @@ HRESULT dt_validate(XDR_DT dt, xmlChar const* content)
xmlDocPtr
tmp_doc
;
xmlNodePtr
node
;
xmlNsPtr
ns
;
xmlSchemaValidCtxtPtr
svctx
;
BOOL
valid
;
HRESULT
hr
;
TRACE
(
"(dt:%s, %s)
\n
"
,
dt_to_str
(
dt
),
wine_dbgstr_a
((
char
const
*
)
content
));
if
(
!
datatypes_schema
)
{
xmlSchemaParserCtxtPtr
spctx
;
assert
(
datatypes_src
!=
NULL
);
spctx
=
xmlSchemaNewMemParserCtxt
((
char
const
*
)
datatypes_src
,
datatypes_len
);
datatypes_schema
=
xmlSchemaP
arse
(
spctx
);
datatypes_schema
=
Schema_p
arse
(
spctx
);
xmlSchemaFreeParserCtxt
(
spctx
);
}
...
...
@@ -539,22 +622,20 @@ HRESULT dt_validate(XDR_DT dt, xmlChar const* content)
assert
(
datatypes_schema
!=
NULL
);
if
(
content
&&
xmlStrlen
(
content
))
{
svctx
=
xmlSchemaNewValidCtxt
(
datatypes_schema
);
tmp_doc
=
xmlNewDoc
(
NULL
);
node
=
xmlNewChild
((
xmlNodePtr
)
tmp_doc
,
NULL
,
dt_to_str
(
dt
),
content
);
ns
=
xmlNewNs
(
node
,
DT_nsURI
,
BAD_CAST
"dt"
);
xmlSetNs
(
node
,
ns
);
xmlDocSetRootElement
(
tmp_doc
,
node
);
valid
=
!
xmlSchemaValidateDoc
(
svctx
,
tmp_doc
);
xmlSchemaFreeValidCtxt
(
svctx
);
hr
=
Schema_validate_tree
(
datatypes_schema
,
(
xmlNodePtr
)
tmp_doc
);
xmlFreeDoc
(
tmp_doc
);
}
else
{
/* probably the node is being created manually and has no content yet */
valid
=
TRUE
;
hr
=
S_OK
;
}
return
valid
?
S_OK
:
S_FALSE
;
return
hr
;
break
;
default:
FIXME
(
"need to handle dt:%s
\n
"
,
dt_to_str
(
dt
));
...
...
@@ -745,7 +826,7 @@ static cache_entry* cache_entry_from_url(char const* url, xmlChar const* nsURI)
entry
->
ref
=
0
;
if
(
spctx
)
{
if
((
entry
->
schema
=
xmlSchemaP
arse
(
spctx
)))
if
((
entry
->
schema
=
Schema_p
arse
(
spctx
)))
{
/* TODO: if the nsURI is different from the default xmlns or targetNamespace,
* do we need to do something special here? */
...
...
@@ -783,7 +864,7 @@ static cache_entry* cache_entry_from_xsd_doc(xmlDocPtr doc, xmlChar const* nsURI
entry
->
ref
=
0
;
spctx
=
xmlSchemaNewDocParserCtxt
(
new_doc
);
if
((
entry
->
schema
=
xmlSchemaP
arse
(
spctx
)))
if
((
entry
->
schema
=
Schema_p
arse
(
spctx
)))
{
xmldoc_init
(
entry
->
schema
->
doc
,
&
CLSID_DOMDocument40
);
entry
->
doc
=
entry
->
schema
->
doc
;
...
...
@@ -812,7 +893,7 @@ static cache_entry* cache_entry_from_xdr_doc(xmlDocPtr doc, xmlChar const* nsURI
entry
->
ref
=
0
;
spctx
=
xmlSchemaNewDocParserCtxt
(
xsd_doc
);
if
((
entry
->
schema
=
xmlSchemaP
arse
(
spctx
)))
if
((
entry
->
schema
=
Schema_p
arse
(
spctx
)))
{
entry
->
doc
=
new_doc
;
xmldoc_init
(
entry
->
schema
->
doc
,
&
CLSID_DOMDocument30
);
...
...
@@ -1257,29 +1338,6 @@ static inline xmlNodePtr lookup_schema_element(xmlSchemaPtr schema, xmlNodePtr n
return
(
decl
!=
NULL
)
?
decl
->
node
:
NULL
;
}
static
void
LIBXML2_LOG_CALLBACK
validate_error
(
void
*
ctx
,
char
const
*
msg
,
...)
{
va_list
ap
;
va_start
(
ap
,
msg
);
LIBXML2_CALLBACK_ERR
(
SchemaCache_validate_tree
,
msg
,
ap
);
va_end
(
ap
);
}
static
void
LIBXML2_LOG_CALLBACK
validate_warning
(
void
*
ctx
,
char
const
*
msg
,
...)
{
va_list
ap
;
va_start
(
ap
,
msg
);
LIBXML2_CALLBACK_WARN
(
SchemaCache_validate_tree
,
msg
,
ap
);
va_end
(
ap
);
}
#ifdef HAVE_XMLSCHEMASSETVALIDSTRUCTUREDERRORS
static
void
validate_serror
(
void
*
ctx
,
xmlErrorPtr
err
)
{
LIBXML2_CALLBACK_SERROR
(
SchemaCache_validate_tree
,
err
);
}
#endif
HRESULT
SchemaCache_validate_tree
(
IXMLDOMSchemaCollection2
*
iface
,
xmlNodePtr
tree
)
{
schema_cache
*
This
=
impl_from_IXMLDOMSchemaCollection2
(
iface
);
...
...
@@ -1297,25 +1355,7 @@ HRESULT SchemaCache_validate_tree(IXMLDOMSchemaCollection2* iface, xmlNodePtr tr
/* TODO: if the ns is not in the cache, and it's a URL,
* do we try to load from that? */
if
(
schema
)
{
xmlSchemaValidCtxtPtr
svctx
;
int
err
;
/* TODO: if validateOnLoad property is false,
* we probably need to validate the schema here. */
svctx
=
xmlSchemaNewValidCtxt
(
schema
);
xmlSchemaSetValidErrors
(
svctx
,
validate_error
,
validate_warning
,
NULL
);
#ifdef HAVE_XMLSCHEMASSETVALIDSTRUCTUREDERRORS
xmlSchemaSetValidStructuredErrors
(
svctx
,
validate_serror
,
NULL
);
#endif
if
((
xmlNodePtr
)
tree
->
doc
==
tree
)
err
=
xmlSchemaValidateDoc
(
svctx
,
(
xmlDocPtr
)
tree
);
else
err
=
xmlSchemaValidateOneElement
(
svctx
,
tree
);
xmlSchemaFreeValidCtxt
(
svctx
);
return
err
?
S_FALSE
:
S_OK
;
}
return
Schema_validate_tree
(
schema
,
tree
);
return
E_FAIL
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment