Your document needs to be: <ns1:datapackage xmlns:ns1="urn:datapackageNS"> <ns1:timestamp>123.3</ns1:timestamp> <ns1:type>type</ns1:type> <ns1:host>host</ns1:host> </ns1:datapackage> The namespace declaration attribute doesn't automatically apply to the name of the tag it's in.
The schema shows there are an unbounded number of Gender elements within the containing GenderDetails element; i.e. Gender is plural, as I originally suggested. So you probably need person.GenderDetails.Gender[0].GenderValue.
If the schema shows GenderValue as a non-plural element within whatever type Gender is the code you show should work. Without seeing the schema I can't tell. The _PluralBinding material is internal to PyXB; some of its visible markers are described here.
A couple things are odd. First, you're referencing GenderDetails but the XML has it spelled genderdetails. Probably one or the other is not what's actually being used. The bigger clue is the reference to PluralBinding which suggests that the Gender element can appear multiple times (which is also a little odd), in which case it's like a list/array and you have to pick which of the elements you want to look at. Or you're spelling the element name wrong. At any rate there isn't enough context here...
PyXB 1.2.4 is almost four years old. The command you provided runs without error on the development version of PyXB, which has minimal changes from 1.2.6 which is the current release. Please update; if you have problems with 1.2.6 please open an issue on github.
Support for PyXB is handled on github. Please open an issue there, describing what you want to accomplish and attaching your (minimized) schema and an example (minimized) program showing that it doesn't do what you expect. The problem should be reproducible with a schema that has at most a single element with a simple type with the defaults.
I'm not getting enough information to tell what the problem is, probably because it depends on your schema. Take the test-issue-0014 example which is self-contained, and change it incrementally until it does what you're trying to do. That should either reveal the problem, or at least provide something you can provide in an issue on github where I could see exactly what's going on.
I think you'd want to do: reg.Extensions._appendWildcardElement(name) to match what the example does.
I think you're adding the class pyxb.utils.saxdom.Element, rather than an instance of a DOM element. So what's there isn't recognized by PyXB. test-issue-0014 has an example of what you're trying to do. See that test case for full context, but you'll want something like this: # Create a namespace and tell PyXB what to call it in generated documents ns2 = pyxb.namespace.Namespace("urn:issue14.2") pyxb.utils.domutils.BindingDOMSupport.DeclareNamespace(ns2, 'n2') # Construct a DOM element for tag e2...
There's not enough detail on what you're doing. If you open an issue on github that reproduces the problem with a simple schema I may be able to assist. However, unless the documents generated by PyXB violate the schema, changes to order of element and content is not a bug: order can only be preserved if order is enforced by the schema.
It may be that the order you are adding them is not consistent with the order required by the schema, or the schema does not require a specific order, or you may be using mixed content. See this section of the manual and the use of pyxb.ValidationConfig.
This forum will no longer be monitored. Please see: https://github.com/pabigot/pyxb/issues/100
This forum will no longer be monitored. Please see: https://github.com/pabigot/pyxb/issues/100
This could probably be done with introspection of the bindings module. Walk it to identify top-level members that subclass pyxb.binding.basis._TypeBinding_mixin, then search for how they appear within other members. For example, class CTD_ANON_5 is added as the type of an element named list in a parent class WebAppList, which itself appears at the type of an element webApps in WasScanTarget. Look in the bindings for things like what's below. WebAppList._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(None,...
PyXB is concerned with validation, and the schema does not enforce an order. What support is provided was intended primarily for preserving order when processing existing documents, and your need to build them up manually may not be supported. For example, using this schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="SCn"> <xs:complexType> <xs:sequence> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="a" type="xs:integer"/>...
Read this page of the manual. You need to generate the bindings for the imported schema first, then generate the bindings for all schema files that define the content of your namespace simutaneously and referencing the bindings for the imported schema. This could be done by generating with schema the includes both command and reply or doing something like: pyxbgen \ -u command.xsd -m command \ -u reply.xsd -m reply \ --archive-path .:+
Rather than setting an attribute on the class, I would use the full customization api to add capabilities through a subclass, even if you're just adding helpers that don't need to affect XML parsing or generation. But it'd probably work the way you're using it. I think m.abc.typeDefinition() would produce a reference to the binding class for the type of element m.abc.
To be more clear, comments are not part of the PyXB binding data model, so you can't put a comment into a binding object and have it expressed as a comment when the object is converted to XML.
BindingDOMSupport is special interface used only to affect how PyXB binding objects are converted to or from DOM instances. Once you have the DOM instance you need to use the xml.dom API to manipulate it. You probably need something like: dom.root.appendChild(dom.createComment('My comment'));
What do you mean by "comment", and how are you adding it? If you have: <element> <subelt>3</subelt> mixed content </element> are you looking to add a real XML comment: <element> <!-- subelt is optional --> <subelt>3</subelt> mixed content </element> or more text, or something else? If you want to add an XML comment then you'll need to convert the PyXB binding object to DOM and operate on the DOM structure. Use obj.toDOM(). If you want to add something to the PyXB binding object whatever you add has...
Archive release 1.2.6
Refine release process
A couple comments: First, if you're not doing it already you probably should use the PyXB bundles for common and gml; otherwise it looks like you get six modules when you could be only generating bindings for the lido namespace: pyxbgen \ --archive-path='&pyxb/bundles/opengis//:&pyxb/bundles/common//' \ -u lido-v1.0.xsd -m lido Also, if you do this: try: root.append(child) except pyxb.ValidationError as e: print(e.details()) you get a little more detail about what's going on. Which is that you've...
A couple comments: First, if you're not doing it already you probably should use the PyXB bundles for common and gml; otherwise it looks like you get six modules when you could be only generating bindings for the lido namespace: pyxbgen \ --archive-path='&pyxb/bundles/opengis//:&pyxb/bundles/common//' \ -u lido-v1.0.xsd -m lido Also, if you do this: try: root.append(child) except pyxb.ValidationError as e: print(e.details()) you get a little more detail about what's going on. Which is that you've...
An example bundle showing how to use the modularized XHTML namespace has been added; see issue 81.
See issue 82.
Thanks; now tracked on github.
Since that schema extends the content model of http://www.w3.org/1999/xhtml you would normally need to add this: --archive-path ${PYXB_ROOT}/pyxb/bundles/common// to your pyxbgen command line. This tells PyXB to import the content model metadata for the bundle that includes the xhtml namespace. The schema still won't generate bindings because it references a model group {http://www.w3.org/1999/xhtml}xhtml.BlkStruct.class that only exists in the modularized version of that namespace, which is not...
If you delete the filler elements from within the sequence, the bindings module can be imported. sed -i -e /filler/d xml-mgmt.xsd
No. The schema element at that point has minOccurs=0 maxOccurs=0 which means it doesn't exist. PyXB seems to remove it, which means the remaining reference to it while building the automaton fails. This is now filed as issue #79. I don't know when it will be worked.
TimePositionType is a complex type with simple content, meaning that it is a basic value that's annotated with attributes. Because you need to access the attributes like calendarEraName from the instance, you have to use the value() method on the instance to access the basic value. Example schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema targetNamespace="URN:test" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="datePrepared" type="gml:TimePositionType"/>...
No. I've never encountered a situation where I've had to do it.
Not a simple way, no. You could use the class _ElementMap and _AttributeMap properties to extract elements and attributes from an instance and put them into a dictionary.
Identified and resolved as github issue #78.
Update your StackOverflow post with the schema description for an element that uses those types and I'll answer it there.
Some of the complexity is required given PyXB's primary goal of supporting XML validation,...
Your addendum is correct. PyXB does not attempt to infer names for the anonymous...
I would expect the multiprocessing module would have to pickle+unpickle the object...
Without reproducing the problem locally there are several clear problems. First,...
That was scheduled for 2.0 seven years ago. It didn't make the cut when unfinished...
Your first issue with trailing zeroes removed is discussed here. PyXB does not support...
It would probably be possible, but you would have to create a modified genbind script...
PyXB delegates to the DOM implementation to generate the document structure. This...
https://github.com/pabigot/pyxb/blob/next/pyxb/utils/xmlre.py
PyXB attempts to translate XML regex syntax into Python syntax for execution. It's...
Yes. You have to change the targetNamespace attribute (which must match the attribute...
The NFe schema variants define incompatible information sets that have the same namespace....
You need the patch for issue #59.
Thanks; I've updated the issue to note that approach should be considered.
As noted in my response on stackoverflow (which I don't monitor regularly), utf8...
The command I gave specifies that the orderedContent order is to be used. I suspect...
In fact, yes. Take a look at this description and this source file. For your example,...
Here the value is a DOM element already, but it's in a micro implementation of DOM...
Yes, that is indeed issue #40. I'm sorry, but I have no plans to fix it. Doing so...
If you want to save time, the problem is this issue which is not likely to be fi...
It depends what you're trying to do. If your intent is to create Python bindings...
I converted that to a complete schema by using xs:string for XType, etc., and adding...
ERROR! The markdown supplied could not be parsed correctly. Did you forget to surround...
OK, I'm back and have been able to play with that schema. Whoever coded that schema...
OK, I'm back and have been able to play with that schema. Whoever coded that schema...
I note that the element in the schema is inertial, not inertia. Other than that,...
I note that the element in the schema is interial, not inertia. Other than that,...
There is no such thing as an anonymous element (all have names), but if the type...
I've opened issue #62 to track this, but in essence the example is correct even if...
I've opened issue #62 to track this, but in essence the example is correct even if...
I've opened issue #62 to track this, but in essence the example is correct even if...
Archive release 1.2.5
Refine release process
The best place for PyXB support is the github issues page. The per-module generated...
It took me a while to figure out what you meant by the 30s example, which I couldn't...
Turns out this is much harder than I can deal with at this time. maxOccurs is a union...
It'll probably touch a couple files.
Apparently this is the first time somebody's pointed PyXB at schema that reference...
No, unloading is not supported. You could try delegating to a subprocess.
If you're still getting references to http://microsoft.com/wsdl/types/ then either...
Delete the old bindings file and regenerate it.
Instead of removing targetNamespace change the namespace value of both it and the...
If the schema have no namespace you could create wrapper schema with unique namespaces...
Interesting; I've never heard of PyCharm and have no idea how it guesses what methods...
The simplest approach would be to add the additional attributes to the DOM object...
C++ was not supported in mspgcc, and mspgcc itself is no longer supported. The error...
For Q1 you usually only need to use BIND in cases where there's an inner element...
Re-reading one of your previous responses and now understanding more about what you...
For DOM structures, you can't, at least not easily or completely. DOM is simply an...
For that simple case: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element...
If you mean you have bindings for which everything could be resolved by PyXB then...
Note: In the previous response, the cbacba.wsdl file processed by the modified pyxbdump...
This can be done, but it's not easy. The PyXB WSDL API assumes a WSDL file contains...
Objects can be constructed either with keyword arguments using the sub-element and...
Converting to DOM doesn't require the whole document. e.toDOM() will generate a fragment...
PyXB is primarily intended for validation. An incomplete element cannot be validated....
PyXB uses the Python standard base64 using the standard_b64decode and standard_b64encode...
No, that feature isn't present. Thel solution requires generating a conforming document...
Schema: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="ct1_t">...
When I last compared (over a year ago), I got a small code size increase with msp430-elf....
mspgcc (which is no longer maintained) does not support link-time optimization with...
When you set RequireValidWhenGenerating(False) generation should not consult the...
ERROR! The markdown supplied could not be parsed correctly. Did you forget to surround...