Assert condition is false with Xerces but true with Saxon - saxon

The specific assert condition is evaluated differently by Xerces and Saxon validation engine in oxygenxml editor.
I have created a xsd schema (version 1.1) and the corresponded xml test file following the created schema. The xml file is correct according to XMLSpy 2019.
The validation of the test xml file in oxygenxml 21.0 fails if Xerces is used as validation schema.
At the same time the validation is successful if Saxon is used as validation engine.
Has the Xerces implementation issues with such particular assert clause
<xs:complexType>
<xs:sequence>
<xs:element name="scenario" type="Scenario"/>
<xs:element name="year" type="StressYear"/>
<xs:element name="position" type="STACreditPosition" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:assert test="every $pos in ./position satisfies not(($pos/geography lt $pos/preceding-sibling::position[1]/geography) or (($pos/geography eq $pos/preceding-sibling::position[1]/geography) and ($pos/creditAssetClass le $pos/preceding-sibling::position[1]/creditAssetClass)))"/>
</xs:complexType>
I expect that the validation is successful with Xerces engine.

You haven't given us enough information to investigate this fully, but you are giving the processor a difficult job with the expression $pos/geography lt ..., because the evaluation depends on the data type of the geography element. The specification says that the assertion should be evaluated using the typed value of geography (for example xs:integer if that's the way it's defined), but this is quite hard to achieve because the expression is evaluated before validation has been completed. So although the result is well-defined according to the specification, you might get more interoperable results if you avoid relying on this feature of the specification, and do an explicit type conversion:
<xs:assert test="every $pos in ./position satisfies
not(($pos/geography/xs:integer(.) lt $pos/preceding-sibling::position[1]/geography/xs:integer(.)) ..."/>

Related

xsd-reverse-enginering throws unknown type

Was playing around with the xsd-reverse-enginering plugin for grails, and got a bit of a problem which I think I know what it is, but not how to resolve it.
Have a huge xsd file containing a relatively advanced schema, and thought I would try to see if I could save my self a lot of time by getting grails to create a gorm object from it. The problem is that the agency that made the xsd file have named a number of XML types based on what the data is. For example, they have an element called MessageType
<xs:element name="MessageCategory" type="MessageType" id="S1.1">
<xs:annotation>
<xs:documentation>The type of message: either an original Submission (NewSubmission), an update on a submission (SubmissionVariation), a complete replacement of one message with another (SubmissionReplacement) or submission that should not have been sent (SubmissionVoid) that should be effectively deleted.</xs:documentation>
</xs:annotation>
</xs:element>
That throws the below error
Unknown simpleType: MessageType
Any ideas on how I can manage this, could I for example define the types or something?
if you want to declare this type you should define the type tags in a proper way (as described here: http://msdn.microsoft.com/en-US/library/8w07bk3h%28v=vs.80%29.aspx)
for instance: a simple type definition (like a number)
<xs:simpleType name="MessageType">
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="100"/>
</xs:restriction>
</xs:simpleType>
a complex type definition (called an element)
<xs:element name="MessageType">
<xs:simpleType ...>
</xs:simpleType>
<xs:simpleType ...>
</xs:simpleType>
</xs:element>

Modifying Wsdl2Apex Generated Classes to Handle xs:extension and imported namespaces

I am having trouble with wsdl2apex code generation, mainly due to the use of xs:import namespace and xs:extension in my WSDL.
In particular, I am seeing the error System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element . . .. The raw SOAP response returned by the web service looks as I would expect.
I would like to modify the generated Apex classes to work around this issue, as server-side changes to the web service is not an option.
The SOAP response looks like the below:
<ns:getAccountsResponse>
<ns:return xsi:type="ax1:AccountReturn">
<ax2:successful>true</ax2:successful>
<ax2:transactionId>1000</ax2:transactionId>
<ax1:Accounts xsi:type="ax1:Account">
And the WSDL looks like this for the ax1 target namespace:
<xs:complexType name="AccountReturn">
<xs:complexContent>
<xs:extension base="ax100:BaseReturnObject">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="Accounts" nillable="true" type="ax1:Account"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
And for the ax2 target namespace:
<xs:complexType name="BaseReturnObject">
<xs:sequence>
<xs:element minOccurs="0" name="successful" type="xs:boolean"/>
<xs:element minOccurs="0" name="transactionId" nillable="true" type="xs:integer"/>
</xs:sequence>
</xs:complexType>
The generated Apex Class which maps to AccountReturn only contains the fields for Accounts in ax1, but not the BaseReturnObject fields in ax2, since the wsdl2apex generation does not respect the use of xs:extension or the importing of namespaces (based on my research).
Is there anyway to modify the Apex Class to make this work? I tried adding the fields from BaseReturnObject to AccountReturn, and modifying field_order_type_info. However, it appears that apex_schema_type_info can only point to one namespace, and this may be the reason that the parsing of the callout response is still failing.
I've built a tool for automating the creation of the Apex classes. It includes support for xs:extension and xs:import (among other things).
In the case of an ex:extension, the tool will pull the required fields from the base class into the subclass and correctly configure the _type_info members.
You can get it for free - FuseIT SFDC Explorer. Currently in only runs directly in Windows. I've had reports of people running it successfully using Wine. (Disclosure: I work for the company that releases this tool).
Incidentally, the salesforce.stackexchange.com site is a great place to ask Salesforce specific questions.

custom binding to force Inner class creation or getters/setters for xs:element

I have a schema declaration as follow from a third-party provider.
<xs:complexType name="GroupParameterType">
<xs:sequence minOccurs="0" maxOccurs="4">
<xs:element name="name" type="xs:string">
<xs:annotation>
<xs:documentation>The name of the parameter.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="value" type="xs:string">
<xs:annotation>
<xs:documentation>The value of the parameter.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
Above is the schema that i CANNOT change. I am trying to write a custom binding for jaxb 2.0 such that I can refer to name as GroupParameterType.Name or GroupParameterType.Value in java code.
Current default binding generates List for me i.e. getNameandValueList, but I want separate getters and setters for name and value respectively.
I tried putting in a custom binding like the following :
<jxb:bindings schemaLocation="GroupParameter.xsd" node="xs:element[#name='name']">
<jxb:globalBindings localScoping="toplevel" generateIsSetMethod="true"/>
</jxb:bindings>
<jxb:bindings schemaLocation="GroupParameter.xsd" node="xs:element[#name='value']">
<jxb:globalBindings localScoping="toplevel" generateIsSetMethod="true"/>
</jxb:bindings>
and it did nothing to change the default class generation. Can anyone give me some pointers as so what else can I try next ? I am looking to have the default List generation ALONG WITH the getters/setters for name and value OR have name and value as Inner Classes. If i remove the maxOccurs=4 option, I can generate getters/setters but since I can't modify the schema, I am trying to get that behavior using external binding file.
Thanks
Shon
You can't get this behaviour unless you modify your schema. You do have a schema model which maps to a heterogeneous element property, and you can't change it with a customization.
You can try the code injection plugin as the last retreat.

svcutil generated unneccesary wrapper classes

I am working on a project that uses the contract first approach. I was given a WSDL and three xsd's. When I use svcutil it generates a wrapper around the response class like so:
public partial class getDataByIdResponse1 {
public getDataByIdResponse getDataByIdResponse;
public getDataByIdResponse1() {
}
public getDataByIdResponse1(getDataByIdResponse getDataByIdResponse) {
this.getDataByIdResponse = getDataByIdResponse;
}
}
The getDataByIdResponse is wrapped inside a getDataByIdResponse1 object. This is done by svcutil and I have no idea why. The getDataByIdResponse1 object does not exist in the WSDL:
<wsdl:message name="getDataById">
<wsdl:part name="response" element="tns:getDataByIdResponse"/>
</wsdl:message>
<xs:element name="getDataByIdResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="data" type="sbc:DataType" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
Why is the type getDataByIdResponse wrapped in getDataByIdResponse1? Is there a switch for svcutil I should have used?
I'm in the same boat as you but I don't just want to live with it. I want to generate clean (unwrapped) contracts. If the wsdl and xsd's were given to you then there are some rules that your schema and wsdl need to follow in order for svc util to generate unwrapped code. These links helped me understand the issue a little better
http://pzf.fremantle.org/2007/05/handlign.html
http://mharbauer.wordpress.com/2007/10/19/wcf-datacontract-serializer-and-documentwrapped/
For now my schema and wsdl are small enough that I can tweak them to adhere to this rules.
However, like Ron, I've also been in situations where the easiest thing is just to live with it.
Hope this helps.
I am in the same situation (contract-first) and svcutil is generating this same kind of code for me but I just closed my eyes took a deep breath and accepted it :-)
Just use the types without the numeric postfix and it just works.

Importing schema with XMLmapper in Delphi?

I try to import some valid schema (for xmlspy and oxygen) with XMLMapper in delphi and I have this error
"Error Flux if:InfofileType unknown".
I use namespace and this type is define in another file.
Is there a way to solve this ?
(I also try with Delphi 2010 demo and it still not work)
<?xml version="1.0" encoding="UTF-8" ?>
- <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:if="http://www.gtest.fr/Apps/InfoFile" xmlns:ca="http://www.gtest.fr/Apps/CommandAnswer" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import namespace="http://www.gtest.fr/Apps/InfoFile" schemaLocation="InfoFile.xsd" />
<xs:import namespace="http://www.gtest.fr/Apps/CommandAnswer" schemaLocation="CommandAnswer.xsd" />
- <xs:element name="ServerAnswer">
- <xs:annotation>
<xs:documentation>Reponse serveur socket</xs:documentation>
</xs:annotation>
- <xs:complexType>
- <xs:sequence>
<xs:element name="InfoFile" type="if:InfoFileType" />
<xs:element name="Command" type="ca:CommandAnswerType" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
reported in QC : http://qc.embarcadero.com/wc/qcmain.aspx?d=80124
I would still try to grab a Delphi 2010 (trial) and see if it works there.
I know there has been significant work done there in D2009 and D2010. It was notoriously bad at doing imports and includes.
Much better now...
If you cannot solve this, I would recommend to manually edit the schemas to remove the include/import and build a big fat XSD without the external file. It should work better.
That's how I did with a rather intricate set of schemas that even .Net lib would choke on.
Update: Could you try to replace the if:InfoFile by another symbol to avoid any clash with the if reserved word; i.e. search 'n' replace if in the schemas by _if_ or anything else... The XML mapper is supposed to care of this but, ya know...
Eric Thorniley finally give me the way to go here.
It seems XML Mapper does not
understand the namespaces correctly.
You can however coax it into life by
adding an extra namespace definition
into the imported files. This is, I am
sure, not right.
So, for instance, in your
Insurance.xsd you declare
xmlns:Utils="http://www.gtest.fr/Apps/Utils"
If you add exactly the same definition
into Utils.xsd, XML Mapper imports it
correctly (I think!)
Ther is a fair chance that XML Spy
would strip out my modifications -
certainly Enterprise Architect ignores
them completely.
I'd like to see the message that Eric Thorniley pointed you to, but it is no longer there. I might be able to find it in an archive somewhere, if I had the subject of the message. I tried a Google search but all I found were duplicate copies of this post on different sites.
Thanks

Resources