Giter Site home page Giter Site logo

xmlns in root node about roxml HOT 10 OPEN

empact avatar empact commented on August 20, 2024
xmlns in root node

from roxml.

Comments (10)

ruckus avatar ruckus commented on August 20, 2024

According to the README ROXML does not support outputting namespaced nodes. Apparently this is planned for a future version.

I've needed the same functionality myself and I've had to override to_xml and build the XML + namespaces manually. Not elegant but it works.

from roxml.

maxmeyer avatar maxmeyer commented on August 20, 2024

Mmmh, thx for the clarification. I consulte the README, but may have overseen that...

from roxml.

benWoz avatar benWoz commented on August 20, 2024

@ruckus We're running into the same issue over here.

Could you detail what you did to override to_xml to build the XML with namespaces? Perhaps point us to some code?

We've got some time to work on this, if we feel like this would be a beneficial contribution for the project.

from roxml.

ruckus avatar ruckus commented on August 20, 2024

@benWoz my approach ended up being fairly manual.

Check out this stuff:

https://github.com/ruckus/quickeebooks/blob/master/lib/quickeebooks.rb#L27

That Model class is a base class, an example concrete class is

https://github.com/ruckus/quickeebooks/blob/master/lib/quickeebooks/model/account.rb

When I have an instance of Account and want to convert it to XML I call to_xml_ns.

This works but feels kinda janky. In the base Model I call to_xml but write it out to a temporary StringIO object that I can mutate even more.

Hope this helps

from roxml.

benWoz avatar benWoz commented on August 20, 2024

@ruckus, thanks for the quick response. I'll take a look at it and see what can be done!

from roxml.

bishboria avatar bishboria commented on August 20, 2024

Any further forward with this?

I'm trying to output the following, e.g.

<example xmlns="http://example.com/">
    <other>stuff</other>
</example>

Right now, I'm doing the following nasty hack:

  to_xml.to_s.sub("example", "example xmlns='http://example.com'")

from roxml.

benWoz avatar benWoz commented on August 20, 2024

I think we ended up taking a different route. Can't remember exactly what &
don't have access to the client's code at this point...

Wish I had more info for you.

  • Ben Woz

On Tue, Jun 19, 2012 at 11:07 AM, Stuart Gale <
[email protected]

wrote:

Any further forward with this?

I'm trying to output the following, e.g.

<example xmlns="http://example.com/"> <other>stuff</other> </example>


Reply to this email directly or view it on GitHub:
#39 (comment)

from roxml.

bishboria avatar bishboria commented on August 20, 2024

That's cool don't worry. My nasty hack works for now... :)

from roxml.

chewi avatar chewi commented on August 20, 2024

A nicer alternative to @bishboria's hack is this...

class Example
  include ROXML
  xml_reader :xmlns, :from => :attr

  def initialize
    @xmlns = "http://example.com"
  end
end

from roxml.

eabartlett avatar eabartlett commented on August 20, 2024

For other folks that run into this - the easiest way I found (outside of forking + patching) is to override to_xml on the class

class Example
  include ROXML
  xml_accessor :some_attribute
  
  def to_xml(params = {})
    params[:namespaces] = { "ns1" => "http://example.com" }
    super
  end
end

from roxml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.