Skip to content

Commit

Permalink
Return <xs:any> and <xs:anyAttribute> from collect_elements/collect_a…
Browse files Browse the repository at this point in the history
…ttributes
  • Loading branch information
ekzobrain committed Apr 17, 2024
1 parent 71d9e64 commit fc73757
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/xsd/base_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def collect_elements(*)
else
# map children recursive
map_children(:*).map do |obj|
if obj.is_a?(Element)
if obj.is_a?(Element) || obj.is_a?(Any)
obj
else
# get elements considering references
Expand All @@ -244,7 +244,7 @@ def collect_attributes(*)
else
# map children recursive
map_children(:*).map do |obj|
if obj.is_a?(Attribute)
if obj.is_a?(Attribute) || obj.is_a?(AnyAttribute)
obj
else
# get attributes considering references
Expand Down
6 changes: 6 additions & 0 deletions lib/xsd/objects/any.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,11 @@ class Any < BaseObject
# @!attribute process_contents
# @return String, nil
property :processContents, :string, default: 'strict'

# Get virtual element name
# @return String
def name
'#any'
end
end
end
6 changes: 6 additions & 0 deletions lib/xsd/objects/any_attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,11 @@ class AnyAttribute < BaseObject
# @!attribute process_contents
# @return String, nil
property :processContents, :string, default: 'strict'

# Get virtual attribute name
# @return String
def name
'#anyAttribute'
end
end
end
4 changes: 4 additions & 0 deletions spec/xsd/xml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,9 @@
it 'reads referenced schemas which bind the xmlschema namespace to the root namespace instead of xs' do
expect(reader['DeclarationOfSoundRecordingRightsClaimMessage'].collect_elements.first.name).to eq 'MessageHeader'
end

it 'returns <xs:any> in collect_elements list' do
expect(reader['ManifestMessage']['FtpMessageHeader']['Signature']['KeyInfo']['X509Data'].collect_elements.last.name).to eq '#any'
end
end
end

0 comments on commit fc73757

Please sign in to comment.