-
Notifications
You must be signed in to change notification settings - Fork 43
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
Allow creation of new Element specifying name and namespace #133
Comments
I can see the use-case, but the method is already "taken": public static Match $(String name, String content) Also, I don't see namespaces as first-class API citizens in this way, but there's certainly room for improvement. Perhaps a namespace setter on a // Set the default namespace on a match
$("rect").xmlns("http://www.w3.org/2000/svg");
// -> <rect xmlns="http://..."/>
// Set the prefixed namespace on a match
$("rect").xmlns("svg", "http://www.w3.org/2000/svg");
// -> <rect xmlns:svg="http://..."/> |
Of course this $("rect").attr("xmlns", "http://www.w3.org/2000/svg"); |
The namespace setter you proposed would be great, but I'm afraid it wouldn't work. I'm not a namespace expert at all, but I found that merely setting the
(EDIT: sorry I wrote the wrong comments, now they're correct) I also managed to create a "namespace-aware" element by calling |
Hmm, good point, I hadn't thought of that. Ah, these namespaces are such a mess :) Perhaps, a new
I'm sure there are other caveats waiting down the line, though. |
That could be a good idea! As far as I understood, both elements and attributes can "belong" to a namespace.
Something I don't understand is where the prefix come from, so I made this simple test:
|
Yes, absolutely!
I'm not sure what you mean...? |
Sorry for not being clear... Please consider this SVG image as example: http://dev.w3.org/SVG/tools/svgweb/samples/svg-files/car.svg (cool, isn't it?)
|
I see now, but unfortunately, I don't know. At Data Geekery, when we created jOOX, we only operated with namespace-less XML. Namespaces are a rather big pain, so we've tried to avoid them. Obviously, this means that jOOX isn't really ready for proper usage of namespaces. In Intuitively, I'd say that namespace declaration attributes are just ordinary attributes with implied semantics (such as the I'm sorry for not being too responsive here, it's just that I don't really know what is the best way to proceed, or if we should proceed at all |
Yes, Anyway, it seems that |
OK, so now we know the constraints. Unfortunately, I'm rather busy with jOOQ right now, so I won't be able to make this a priority for jOOX. I mean, we could get something to work quickly, but it would risk not being very good... |
No problem, of course. I can create the namespace-aware elements anyway with the jQuery style:
Thanks for considering the proposal. |
@lukaseder you mentioned in this issue:
How do you avoid name conflicts? https://www.w3schools.com/XML/xml_namespaces.asp |
@pmihalcin Well, we don't have any conflicts. It's possible to use XML without namespaces or with single, implied namespaces. XML with mixed namespaces is quite a different beast, and has, so far, been mostly out of scope for jOOX. |
A very nice feature is the new element creation specifying only the tag name (e.g.
$("p")
).I think it may be useful to allow the creation of an element specifying both the tag name and the namespace:
$(String name, String namespace)
.In my case, I need to create SVG element, so instead of writing something like
I could write something more concise:
Of course, this is something that doesn't exist in jQuery, so if you want to keep the API similar this proposal doesn't make sense.
The text was updated successfully, but these errors were encountered: