Comments (10)
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.
Mmmh, thx for the clarification. I consulte the README, but may have overseen that...
from roxml.
@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.
@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.
@ruckus, thanks for the quick response. I'll take a look at it and see what can be done!
from roxml.
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.
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.
That's cool don't worry. My nasty hack works for now... :)
from roxml.
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.
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)
- 3.1.6 is not compatible with activesupport 2.3.x HOT 4
- Unable to read collection into Array HOT 2
- Ability to traverse to the parent object
- know if a tag is empty or not HOT 1
- After marshalling/unmarshalling nil is frozen HOT 1
- unable to run any tests HOT 4
- One test is failing: ROXML::XML should raise on malformed xml HOT 3
- Conditionally combining multiple attributes
- undefined method `each' for "":String in ruby 1.9.3 HOT 4
- RequiredElementMissing is a subclass of Exception HOT 1
- wishlist: port spec suite to RSpec3 HOT 2
- spec/regression_spec.rb fails with ruby2.2 HOT 2
- Generating XML from object without indentation
- Ignoring attribute when converting object to xml HOT 1
- warning: constant ::Fixnum is deprecated HOT 1
- Please release new gem version HOT 5
- Please release a new gem version HOT 12
- Obsolete references to URI.escape and URI.unescape HOT 18
- cannot load such file -- rexml/xpath_parser
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from roxml.