Skip to content

Commit

Permalink
Fix resolving schemas with unprefixed namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzobrain committed Apr 25, 2024
1 parent 9cd7082 commit 0e3c787
Show file tree
Hide file tree
Showing 4 changed files with 416 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/xsd/base_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def nodes(name = :*, deep = false)
# @return Array<Schema>
def schemas_for_namespace(ns_or_prefix)
# resolve namespace for current node if prefix was provided
prefix = node.namespaces["xmlns:#{ns_or_prefix}"]
prefix = node.namespaces[['xmlns', (ns_or_prefix == '' ? nil : ns_or_prefix)].compact.join(':')]
ns = prefix || ns_or_prefix

if schema.targets_namespace?(ns)
Expand Down
297 changes: 297 additions & 0 deletions spec/fixtures/retail_license_notification/commons/Types.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,297 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="urn://fsrar/smev/retail_license_notification/types/1.0.0" targetNamespace="urn://fsrar/smev/retail_license_notification/types/1.0.0" elementFormDefault="qualified">
<xs:complexType name="DocumentType">
<xs:sequence>
<xs:element name="Number" type="s50">
<xs:annotation>
<xs:documentation>Номер</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Date" type="xs:date">
<xs:annotation>
<xs:documentation>Дата</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="d2">
<xs:annotation>
<xs:documentation>число с ограничением длины до 2 цифр</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:decimal">
<xs:totalDigits value="2"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="d25">
<xs:annotation>
<xs:documentation>число с ограничением длины до 25 цифр</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:decimal">
<xs:totalDigits value="25"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s20">
<xs:annotation>
<xs:documentation>текст длиной до 20 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="20"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s12">
<xs:annotation>
<xs:documentation>текст длиной до 12 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="12"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s400">
<xs:annotation>
<xs:documentation>текст длиной до 400 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="400"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s50">
<xs:annotation>
<xs:documentation>текст длиной до 50 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s255">
<xs:annotation>
<xs:documentation>текст длиной до 255 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="d1">
<xs:annotation>
<xs:documentation>число с ограничением длины до 1 цифр</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:decimal">
<xs:totalDigits value="1"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="d3">
<xs:annotation>
<xs:documentation>число с ограничением длины до 3 цифр</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:decimal">
<xs:totalDigits value="3"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="d9">
<xs:annotation>
<xs:documentation>число с ограничением длины до 9 цифр</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:decimal">
<xs:totalDigits value="9"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="d10">
<xs:annotation>
<xs:documentation>число с ограничением длины до 10 цифр</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:decimal">
<xs:totalDigits value="10"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="d13">
<xs:annotation>
<xs:documentation>число с ограничением длины до 13 цифр</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:decimal">
<xs:totalDigits value="13"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="d15">
<xs:annotation>
<xs:documentation>число с ограничением длины до 15 цифр</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:decimal">
<xs:totalDigits value="15"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="d12">
<xs:annotation>
<xs:documentation>число с ограничением длины до 12 цифр</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:decimal">
<xs:totalDigits value="12"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s9">
<xs:annotation>
<xs:documentation>текст длиной до 9 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="9"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s10">
<xs:annotation>
<xs:documentation>текст длиной до 10 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="10"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s100">
<xs:annotation>
<xs:documentation>текст длиной до 100 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="100"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s1000">
<xs:annotation>
<xs:documentation>текст длиной до 1000 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="1000"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s10000">
<xs:annotation>
<xs:documentation>текст длиной до 10000 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="10000"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s15">
<xs:annotation>
<xs:documentation>текст длиной до 15 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="15"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s19">
<xs:annotation>
<xs:documentation>текст длиной до 19 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="19"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s25">
<xs:annotation>
<xs:documentation>текст длиной до 25 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="25"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s200">
<xs:annotation>
<xs:documentation>текст длиной до 200 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="200"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s2000">
<xs:annotation>
<xs:documentation>текст длиной до 2000 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="2000"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s250">
<xs:annotation>
<xs:documentation>текст длиной до 250 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="250"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s254">
<xs:annotation>
<xs:documentation>текст длиной до 254 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="254"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s30">
<xs:annotation>
<xs:documentation>текст длиной до 30 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="30"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s32">
<xs:annotation>
<xs:documentation>текст длиной до 32 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="32"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s300">
<xs:annotation>
<xs:documentation>текст длиной до 300 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="300"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s4">
<xs:annotation>
<xs:documentation>текст длиной до 4 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="4"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s40">
<xs:annotation>
<xs:documentation>текст длиной до 40 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="40"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s4000">
<xs:annotation>
<xs:documentation>текст длиной до 4000 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="4000"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s500">
<xs:annotation>
<xs:documentation>текст длиной до 500 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="500"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s64">
<xs:annotation>
<xs:documentation>текст длиной до 64 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="64"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="s900">
<xs:annotation>
<xs:documentation>текст длиной до 900 символов</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="900"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
Loading

0 comments on commit 0e3c787

Please sign in to comment.