Skip to content
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

LibXML error when calling #to_xml more than once on a command with extension loaded #10

Open
jph opened this issue Nov 25, 2015 · 0 comments

Comments

@jph
Copy link

jph commented Nov 25, 2015

Full text of error:

LibXML::XML::Error:  Nodes belong to different documents.  You must first import the node by calling XML::Document.import.
from gems/epp-client-2.1.0/lib/epp-client/requests/extension.rb:21:in `<<'

This may be as simple as me not setting namespaces (I've found a few methods called 'set_namespaces') but I'm unable to see exactly how to set these manually.

Below are steps to reproduce.

@domain_update = EPP::Domain::Update.new('example.com',
  :add => {:ns => %w(ns1.test.host ns2.test.host)},
  :rem => {:ns => %w(ns3.test.host ns4.test.host)},
  :chg => {
    :registrant => 'UK-2349723',
    :auth_info => {:pw => '2381728348'}
})

@update = EPP::Commands::Update.new(@domain_update)

explanation = 'explanation'
method = 'update'

# XML GENERATION
      xml = XML::Node.new(method)
      xml.namespaces.namespace = ns = XML::Namespace.new(xml, 'auext', 'urn:X-au:params:xml:ns:auext-1.1')
      xattr = XML::Attr.new(xml, 'schemaLocation', 'urn:X-au:params:xml:ns:auext-1.1 auext-1.1.xsd')
      xattr.namespaces.namespace = XML::Namespace.new(xml, 'xsi', 'http://www.w3.org/2001/XMLSchema-instance')
      au_properties = XML::Node.new('auProperties', '', ns)

      au_properties << node = XML::Node.new('registrantName',  'Registrant Name', ns)
      au_properties << node = XML::Node.new('registrantID',    'Registrant ID', ns)
      node['type'] = 'Registrant ID Type'
      au_properties << node = XML::Node.new('eligibilityName', 'Elig Name', ns)
      au_properties << node = XML::Node.new('eligibilityType', 'Elig Type', ns)
      au_properties << node = XML::Node.new('eligibilityID',  'Elig ID', ns)
      node['type'] = 'Elig Type'
      au_properties << node = XML::Node.new('policyReason', '1', ns)

      xml << au_properties
      xml << XML::Node.new('explanation', explanation, ns) if explanation
# XML GENERATION

@extension = EPP::Requests::Extension.new(xml)

@command = EPP::Requests::Command.new(SecureRandom.uuid, @update, @extension)
@request = EPP::Request.new(@command)

puts @request.to_xml # => this works
puts @request.to_xml # => this throws LibXML::XML::Error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant