Fixes that should allow SAML to work have been integrated into the git
repository.  If you do something like:

git checkout git://pyxb.git.sourceforge.net/gitroot/pyxb/pyxb
cd pyxb
git checkout next

you should get a workspace that has the changes.  You can use git to extract
the patches and apply them to your area, or just install from the workspace.

Sorry I can't help more right now; this seems to be the week for bug
reports, and I have two higher-priority projects I have to take care of.  I
may be able to get a new PyXB version out within a week or so that will
integrate these changes, if you can't use the git repository for some
reason.

Peter

On Thu, Nov 4, 2010 at 8:50 AM, Peter Bigot <big...@acm.org> wrote:

> <http://www/Documentation/W3C/www.w3.org/TR/xmlschema-2/index.html>I've
> added pyxb-users to this discussion to increase visibility.
>
> One conceptual problem is that an XML element is not a first-class object
> in
> PyXB.  An element is simply an association of a name and some other data
> with a type.  PyXB does not really support creating instances of elements.
> What it supports is creating instances of a type.
>
> If you have a schema the defines an element MyElement, when you invoke:
>
>    MyElement(x)
>
> what you're really doing is invoking something like:
>
>    MyElement.typeDefinition().__init__(x, _element=MyElement)
>
> which creates the instance of the underlying type, but records its origin
> as
> being associated with the given element.
>
> In your case, since AttributeValue is of type xs:anyType, for which there
> are no real instances, what you want to do is something like:
>
>   v = xs.string('abc', _element=AttributeValue)
>
> Then when you do:
>
>   v.toxml()
>
> the context from the associated element will affect the formatting, and
> you'll get:
>
>   <ns1:anything xmlns:ns1="urn:test" xmlns:ns2="
> http://www.w3.org/2001/XMLSchema"; xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance";
> xsi:type="ns2:string">foo</ns1:anything>
>
> which can be cleaned up using BindingDOMSupport.DeclareNamespace.
>
> (Note that for this to work, you'll need a patch to
> http://sourceforge.net/apps/trac/pyxb/ticket/95, which is in development.)
>
> In fact, it should be unnecessary to add the _element keyword to the
> constructor if you intend to assign the value to an element with a
> compatible type.  If the value is of a consistent type, you can just use
> it.
> This is what PyXB does normally.  It causes problems in SAML2 because of
> its
> declaration:
>
>
>   <element name="AttributeValue" type="anyType" nillable="true"/>
>
> Although http://www.w3.org/TR/xmlschema-1/#xsi_type indicates how xsi:type
> can convey the actual type of the content, doing so does not itself allow
> xs:string to validate against xs:anyType.  My earlier reading of the
> specifications suggested that such elements should be declared as abstract,
> and the validation is allowed through the use of substitution groups.  In
> this case, the problem is compounded because you're using an instance of a
> simple type to match against a completely unconstrained type which is
> normally assumed to be a complex type.
>
> At any rate, I'm working on a patch that will address this and your
> http://sourceforge.net/apps/trac/pyxb/ticket/94.  You may need to switch
> to
> using the development version of PyXB out of git to test it, as it takes
> about a half-day's work just to go through the steps required to push out a
> new PyXB version and I don't want to do that until I know things work.
>
> I'll let you know when there's something to try.
>
> Peter
>
>
> On Wed, Nov 3, 2010 at 6:24 AM, Dieter Maurer <die...@handshake.de> wrote:
>
>> Hello Peter,
>>
>>
>> as you have supposed, the formerly reported problem went away
>> after I have removed the old installation, cleanly reinstalled version
>> 1.1.2
>> and then recreated all bindings. Thank you!
>>
>>
>> My next problem occurs with the binding of the SAML2 element
>> "AttributeValue", defined by the schema fragment
>> <element name="AttributeValue" type="anyType" nillable="true"/>
>>
>> Corresponding elements should look like
>>
>>  <AttributeValue xsi:type="xs:string">abc</AttributeValue>
>>
>> But, I cannot yet create such elements from Python.
>>
>> I have tried:
>>
>>  *  AttributeValue('abc')
>>
>>  *  AttributeValue(pyxb.BIND('abc'))
>>
>>  *  AttributeValue(pyxb.binding.datatypes.string('abc'))
>>
>> The former two complain about a missing namespace,
>> the latter creates:
>>
>>  <AttributeValue><xs:string>abc</xs:string></AttributeValue>
>>
>> Can you give me a hint how to precisely control the creation
>> of binding instances of "xs:anyType"?
>>
>>
>>
>> --
>> Dieter
>>
>
>
------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
pyxb-users mailing list
pyxb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyxb-users

Reply via email to