I am trying to create a Group.
Based on your documentation, I can create a "name" associated with that group in the source editor but I can't through the GUI. If I try and create one manually in the source it says that "name is not a valid attribute for group".
What am I doing wrong? I would like to add this for grouping like items.
<xs:schema elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="myElm">
<xs:complexType>
<xs:sequence>
<xs:group name="myGroup" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Only the root element can have a name. When you reference it for inclusion, the name attribute is not valid.
Adding a name attribute in where is is referenced (i.e. ) will result in the error "name is not a valid attribute for group".
This conforms to the W3C XSD Standard. Using the UI it is not possible to perform this action, as name is not available, however you can do this by changing the source code.
<?xml version="1.0" encoding="utf-8" ?>
<!--Created with Liquid XML Studio - 30 Day Trial Edition 7.0.0.604 (http://www.liquid-technologies.com)-->
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:group name="myGroup" />
<xs:element name="myElm">
<xs:complexType>
<xs:sequence>
<xs:group ref="myGroup" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
You can then add a particle (sequence/choice/all) to the group definition anb build up groups of elements that can be re-used as a block.
Related
Is it possible with XSD to allow a limited set of child nodes names, but allow 0-unlimited instances of each, in any order?
So far as I can tell ns:any allows any order, but no more than one instance of each, ns:sequence requires the specified order while ns:choice limits you to only one of the list.
But I also seemingly can't just have a ns:simpleType or ns:complexType with no order indicator.
Alternatively, I could import my XML without validating against an XSD, then validate each of those required nodes against their own XSD, but I can't seem to find a way to validate an [Xml.Element] directly. Perhaps I could take each of the nodes and create a temporary [Xml.Document] from it to validate, but as far as I can tell the only way to validate XML against an XSD is when reading from a file, and writing a temporary file hundreds to thousands of times just to validate a node seems horribly inefficient.
I have spent more than a little time developing my XSD, so I hope there is an XSD based solution. But at least all this work has resulted in much more consistent XML than I would have otherwise had, and the XSD exercise provides a specification of sorts for the code I need to validate the XML. Some consolation there.
EDIT: The potential solution I have found is to make an ns:group, that contains an ns:choice that contains all the child nodes as minOccurs='0' maxOccurs='1', then reference that group where those nodes are needed with <xs:group ref="TaskGroup" minOccurs='0' maxOccurs='unbounded'/>. Still not ideal as another subtlety is in two places I need JUST the tasks (of which there are maybe 30) and in one other location I also need to allow for a node called <package> that can be interspersed with the other task nodes. At which point I have two groups where the vast majority is the same 30 tasks and the only difference is one also has a <package>. And there seems to be no way to use ns:group, ns:union and ns:choice together to get the required result. Damn you Microsoft!
Ugly, and I may still just abandon XSD and code my own validation.
EDIT: I did try using an ns:extension like this, and I get an error that The 'http://www.w3.org/2001/XMLSchema:extension' element is not supported in this context.
<xs:complexType name='TaskList'>
<xs:choice>
<xs:element name='taskCopy' type='Task_Copy' minOccurs='0' maxOccurs='1'/>
<xs:element name='taskCreateFolder' type='Task_CreateFolder' minOccurs='0' maxOccurs='1'/>
<xs:element name='taskDelete' type='Task_Delete' minOccurs='0' maxOccurs='1'/>
<xs:element name='taskExecuteProgram' type='Task_ExecuteProgram' minOccurs='0' maxOccurs='1'/>
<xs:element name='taskInstallProgram' type='Task_InstallProgram' minOccurs='0' maxOccurs='1'/>
<xs:element name='taskInventoryHardware' type='Task_InventoryHardware' minOccurs='0' maxOccurs='unbounded'/>
<xs:element name='taskInventorySoftware' type='Task_InventorySoftware' minOccurs='0' maxOccurs='unbounded'/>
<xs:element name='taskManageAsset' type='Task_ManageAsset' minOccurs='0' maxOccurs='1'/>
<xs:element name='taskManageNetworkLocation' type='Task_ManageNetworkLocation' minOccurs='0' maxOccurs='1'/>
<xs:element name='taskManageManageMappedDrive' type='Task_ManageManageMappedDrive' minOccurs='0' maxOccurs='1'/>
<xs:element name='taskManageZipFile' type='Task_ManageZipFile' minOccurs='0' maxOccurs='1'/>
<xs:element name='taskMirror' type='Task_Mirror' minOccurs='0' maxOccurs='1'/>
<xs:element name='taskSetRegistryValue' type='Task_SetRegistryValue' minOccurs='0' maxOccurs='1'/>
</xs:choice>
</xs:complexType>
<xs:complexType name='PackageList'>
<xs:extension base="TaskList">
<xs:choice>
<xs:element name='package' type='xs:string' minOccurs='0' maxOccurs='1'/>
</xs:choice>
</xs:extension>
</xs:complexType>
So, it seems to me that, in XSD 1.0 at least, ns:choice is very limited and cannot be unioned or extended.
EDIT2: To clarify, this is a simplified example of what my XML looks like.
<packages>
<package id="ParentPackage">
<taskCopy id="SimpleTask">
<process>
<source>PATH TO... source</source>
<destination>PATH TO... destination</destination>
</process>
</taskCopy>
<package>NestedPackage</package>
<taskCopy id="ComplexTask">
<preprocess>
<taskDelete>
<process>
<path>[Product~Journals]\*</path>
</process>
</taskDelete>
</preprocess>
<process>
<source>PATH TO... source</source>
<destination>PATH TO... destination</destination>
</process>
</taskCopy>
</package>
<package id="NestedPackage">
<taskCopy id="AnotherSimpleTask">
<process>
<source>PATH TO... source</source>
<destination>PATH TO... destination</destination>
</process>
</taskCopy>
</package>
</packages>
There are 30 different Task options, and any of them can occur nested within the <preprocess> node of a Task. They can also occur in a <package>, but a package can also contain another nested <package>, which itself contains tasks and packages. Order is variable for both tasks and packages.
The goal is to not need to maintain duplicate task lists to handle the difference between what can be in a package node and what can be in a task preprocess node.
Define a complex type that contains a choice with all the optional childs and assign that complex type to the parent of all the childs.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Root" type="randomType"/>
<xs:complexType name="randomType">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="a"/>
<xs:element name="b"/>
<xs:element name="c"/>
</xs:choice>
</xs:complexType>
</xs:schema>
an xml like this is then still valid
<?xml version="1.0" encoding="UTF-8"?>
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<b>a</b>
<a>text</a>
<b>a</b>
<b>a</b>
<b>a</b>
<b>a</b>
<b>a</b>
<a>text</a>
</Root>
I'm trying to make a SOAP request where a parameter is a complex type, and I'm having trouble getting the syntax right.
WSDL: https://www.dayforcehcm.com/DataSvc/DayforceService.svc?singleWsdl
Action: IDayforceService/Query
Here is the SOAP request that was generated by SoapUI:
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://Dayforce/Services/DayforceService">
<SOAP-ENV:Body>
<ns1:Query>
<ns1:sessionTicket>?</ns1:sessionTicket>
<ns1:request/>
</ns1:Query>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
My question is how to fill in the <ns1:request/> element. The request should be a GetReportDefinitionsRequest, and it needs to provide a string value for XRefCode.
SoapUI isn't being much help here, and WSDL to class generators I've tried have similar problems. At this point I'd settle for just knowing the proper XML syntax
Here are the relevant types (also available in the WSDL above).
Query:
<xs:element name="Query">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="sessionTicket" nillable="true" type="xs:string"/>
<xs:element xmlns:q9="http://Dayforce/Services/Data" minOccurs="0" name="request" nillable="true" type="q9:DFRequest"/>
</xs:sequence>
</xs:complexType>
</xs:element>
GetReportDefinitionsRequest:
<xs:complexType name="GetReportDefinitionsRequest">
<xs:complexContent mixed="false">
<xs:extension base="tns:DFRequest">
<xs:sequence>
<xs:element minOccurs="0" name="XRefCode" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="GetReportDefinitionsRequest" nillable="true" type="tns:GetReportDefinitionsRequest"/>
DFRequest:
<xs:complexType name="DFRequest">
<xs:complexContent mixed="false">
<xs:extension base="tns:DFObject">
<xs:sequence/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="DFRequest" nillable="true" type="tns:DFRequest"/>
DFObject:
<xs:complexType name="DFObject">
<xs:sequence/>
</xs:complexType>
<xs:element name="DFObject" nillable="true" type="tns:DFObject"/>
I was able to get the sample code running and hook in to get the XML generated for the request. Here's the result, in case it helps anyone in the future.
The important part is to assign the type attribute to the tag. That involves importing the http://www.w3.org/2001/XMLSchema-instance namespace to get the type attribute, and the http://Dayforce/Services/Data namespace for the type itself.
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:dfs="http://Dayforce/Services/DayforceService">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<dfs:Query>
<dfs:sessionTicket>?</dfs:sessionTicket>
<dfs:request
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dfd="http://Dayforce/Services/Data"
i:type="dfd:GetReportDefinitionsRequest">
<dfd:XRefCode>?</dfd:XRefCode>
</dfs:request>
</dfs:Query>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I need to re use a status tag that I created in an XSD. For example in our order company we have several statuses. Status of an order- car order, truck order etc.
The tags that need to be used are unfortunately not the same. For the car it is a carStatus and for the truck it is a truckStatus but the underlying object are the same. It is a xs:string tag that has an enumeration of COMPLETED, BUSY or AWAITING INFORMATION.
Now I don not want to have 16 tags for 16 objects (car, track, chopper... -Status). Tomorrow if we add another status I have to go to all of these elements and update it.
My XSD where I reference the GenericCodeStatus looks as follows
<xs:schema targetNamespace="http://www.myDomain.co.za/myCoreXsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mine="http://www.myDomain.co.za/myCoreXsd" elementFormDefault="qualified" attributeFormDefault="unqualified">
<!-- Defining my Enum -->
<xs:element name="GenericCodeStatus">
<xs:annotation>
<xs:documentation>Generic code status</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="COMPLETED"/>
<xs:enumeration value="BUSY"/>
<xs:enumeration value="AWAITING INFORMATION"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<!-- Here I have mytag where I am referencing the genericCodeStatus -->
<xs:complexType name="MyTag1">
<xs:sequence>
<xs:element ref="mine:GenericCodeStatus"/>
</xs:sequence>
</xs:complexType>
Now the thing is that I want to have the genericCodeStatus under MyTag1 to have a name.
I tried creating it with a name and type tag (and i am using XML Spy as an editor)
<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://www.myDomain.co.za/myCoreXsd" xmlns:mine="http://www.myDomain.co.za/myCoreXsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" elementFormDefault="qualified" attributeFormDefault="unqualified">
<!-- Defining my Enum -->
<xs:element name="GenericCodeStatus">
<xs:annotation>
<xs:documentation>Generic code status</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="COMPLETED"/>
<xs:enumeration value="BUSY"/>
<xs:enumeration value="AWAITING INFORMATION"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:complexType name="MyTag1">
<xs:sequence>
<!-- Taken this out -->
<xs:element ref="mine:GenericCodeStatus"/>
<!-- and replace it with name and type -->
<xs:element name="carStatus" type="mine:GenericCodeStatus"/>
</xs:sequence>
</xs:complexType>
But then get an error of an undefined value for 'type' encountered error.
I have also tried removing the 'mine' namespace.
If I try to replace the type with a ref as in
<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://www.myDomain.co.za/myCoreXsd" xmlns:mine="http://www.myDomain.co.za/myCoreXsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" elementFormDefault="qualified" attributeFormDefault="unqualified">
<!-- Defining my Enum -->
<xs:element name="GenericCodeStatus">
<xs:annotation>
<xs:documentation>Generic code status</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="COMPLETED"/>
<xs:enumeration value="BUSY"/>
<xs:enumeration value="AWAITING INFORMATION"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:complexType name="MyTag1">
<xs:sequence>
<!-- Taken this out -->
<xs:element ref="mine:GenericCodeStatus"/>
<!-- and replace it with name and ref -->
<xs:element name="carStatus" ref="GenericCodeStatus"/>
</xs:sequence>
</xs:complexType>
The validation works fine but if I save it XML Spy is removing the name element and I am back to where I started.
If anyone knows please?
I found the answer to this but thought of still posting this as it was difficult to find. Thanks to a buddy of mine :)
I should not define the Element like I did and then try to reference it over and over each time with a new name.
What I should do is to define the simpleType on its own and give it a name.
<!-- Define the simpleType as an enum and give it a name -->
<xs:simpleType name="myCoolDataType">
<xs:restriction base="xs:string">
<xs:enumeration value="COMPLETED"/>
<xs:enumeration value="BUSY"/>
<xs:enumeration value="AWAITING INFORMATION"/>
</xs:restriction>
</xs:simpleType>
Then where I want to use it I need to define the element and just give it a type with the value you gave to the enum in the first stip
<xs:complexType name="MyTag1">
<xs:sequence>
<xs:element name="truckStatus" type="mine:myCoolDataType"/>
<xs:element name="carStatus" type="mine:myCoolDataType"/>
</xs:sequence>
</xs:complexType>
Can anyone suggest a good tutorial on how to add new operations to already existing webservices?I referred many tutorials but most are discussing about creating a new wsdl and then changing it.I also referred the following and when i tried it, the design view is not showing the names of existing ports.PLZ help by giving me suitable advice.
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.wst.wsdl.ui.doc.user%2Ftasks%2Ftcrtwsdl.html
If the web service already exists you can edit the existing interface and code behind to add the new operations.
Once you have done this you should be able to use a tool to generate a new WSDL which can be deployed along with your updated service.
The following tool; Java2WSDL should help, http://axis.apache.org/axis/java/user-guide.html#Java2WSDL:_Building_WSDL_from_Java
Hope this helps.
Add an element in XSD file and map local part to new method in endpoint controller. getCountryRequest is existing operation in below XSD and I have added getCountryByCurrencyRequest.
<xs:element name="getCountryRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getCountryResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="country" type="tns:country" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getCountryByCurrencyRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
I'm using GData as my XML parser.
I've tried using an XPath query to retrieve a node -
#"//GetPlacesAutoCompleteResult".
but getNodesForXPath doesn't return any nodes.
so I'm asking, what's wrong with the query I typed in?
P.S
I'm only looking for a way to find out if the node exists or not, I care not about it's child nodes.
here is my .xml file (a result from a soap query to an .ASMX Web-Service).
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetPlacesAutoCompleteResponse
xmlns="http://xxxxxxx.com/xxxxxx/webservice">
<GetPlacesAutoCompleteResult>
<xs:schema id="NewDataSet"
xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet"
msdata:IsDataSet="true"
msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0"
maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="ID"
type="xs:long"
minOccurs="0"/>
<xs:element name="FullName"
type="xs:string"
minOccurs="0"/>
<xs:element name="PlaceTypeID"
type="xs:int"
minOccurs="0"/>
</xs:sequence>
</xs:complexType></xs:element>
</xs:choice>
</xs:complexType></xs:element>
</xs:schema>
<diffgr:diffgram
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<Table diffgr:id="Table1" msdata:rowOrder="0">
<ID>47393</ID>
<FullName>Yifat</FullName>
<PlaceTypeID>10</PlaceTypeID>
</Table>
<Table diffgr:id="Table2" msdata:rowOrder="1">
<ID>48497</ID>
<FullName>Haifa</FullName>
<PlaceTypeID>10</PlaceTypeID>
</Table>
<Table diffgr:id="Table3" msdata:rowOrder="2">
<ID>70827</ID>
<FullName
>Haifa - Central Bus Rishon</FullName>
<PlaceTypeID>120</PlaceTypeID>
</Table>
</NewDataSet>
</diffgr:diffgram>
</GetPlacesAutoCompleteResult>
</GetPlacesAutoCompleteResponse>
</soap:Body>
</soap:Envelope>
Well with <GetPlacesAutoCompleteResponse xmlns="http://xxxxxxx.com/xxxxxx/webservice"><GetPlacesAutoCompleteResult> you have a default namespace declaration in scope so assuming you use XPath 1.0 you need to bind a prefix to the namespace URI http://xxxxxxx.com/xxxxxx/webservice and use that prefix to qualify element names. For example if the prefix is ws then you would use //ws:GetPlacesAutoCompleteResult.
How you bind a prefix to a namespace URI depends on the XPath API you use, I am not familiar with GData so I can't help you with a code sample.