-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with base-uri in assertion #379
Comments
Hi, It could be an issue of the XPath processor (elementpath). The function base-uri() returns the base-uri property of the XPath node (if the context item is an XPath node). thank you |
Hi @brunato,
|
A resolution for this will require an enhancement of the XPath processor (maybe an additional argument for DocumentNode class), and then a change in As a workaround until that, you could add a specific xml:base attribute in XML root element, e.g.: import xmlschema
my_schema = xmlschema.XMLSchema11('xmlschema-test.xsd',use_xpath3=True)
resource = xmlschema.XMLResource('test.xml')
resource.root.attrib['{http://www.w3.org/XML/1998/namespace}base'] = resource.uri
my_schema.validate(resource) |
Thanks for quick reply, but we seem to have a problem with parsing our xsd first (we thought this happens because of base-uri but if we only leave XMLSchema11 we get an error as well), so this happens even before xml is validated. This is XSD is valid because we can validate it with Altova. `Traceback (most recent call last): Schema component: <xs:assert xmlns:xs="http://www.w3.org/2001/XMLSchema" test="let $xml_file_path := string(base-uri()), $last_slash_pos := index-of(string-to-codepoints(upper-case(string(base-uri()))), string-to-codepoints('/'))[last()], $xml_file_name := substring($xml_file_path, $last_slash_pos + 1), $schema_file_location := @xsi:noNamespaceSchemaLocation, $schema_last_slash_pos := index-of(string-to-codepoints($schema_file_location), string-to-codepoints('/'))[last()], $schema_name := substring($schema_file_location, $schema_last_slash_pos + 1), $schema_type := substring-before(substring-after(substring-after($schema_name, '.'), '.'), '.'), $schema_type_upper := upper-case($schema_type), $regex_pattern := concat('^', $schema_type_upper, '_.*') return matches($xml_file_name, $regex_pattern)"> XSD that is causing these problems: |
The problem maybe the same and happens during the XPath static analysis. I've no workaround for this, you have to wait for a fix in elementpath package. |
Hi, Probably there could be other thing to adjust on this, also for assertion dynamic evaluation on XML data, so I wait for your feedback on XML validation cases. |
Seem to be fine now, if not re-open this issue. |
Hi,
first of all thanks for 3.0.0 release! Right now we have a problem with validation against assertion that check filename.
$xml_file_path := upper-case(string(base-uri())),
Validate function acts as if there was no filename. Is there any way to set this up so base-uri returns filename properly?
The text was updated successfully, but these errors were encountered: