I am writing an xml file in klish. I want to know how can we auto complete an parameter by pressing tab button in klish xml files. For E.g. I want user to enter either enable or disable on klish command line but if user press 'e' and tab then automatically enable should be completed or if user presses 'd' and tab then automatically disable should come.
I am receiving these parameter on klish command line by user.
And also can we define macros in klish xml files so that i can use that macro in klish ACTION tag to pass that macro value as a parameter to my c file
My XML code is like this :-
<?xml version="1.0" encoding="UTF-8"?>
<CLISH_MODULE xmlns="http://clish.sourceforge.net/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://clish.sourceforge.net/XMLSchema
http://clish.sourceforge.net/XMLSchema/clish.xsd">
<!--=======================================================-->
<COMMAND name="show"
help="some utility commands for show"/>
<COMMAND name="show connection"
help="Show the connection">
<DETAIL>
connection status
</DETAIL>
<ACTION>c_file.c 1</ACTION>
</COMMAND>
<COMMAND name="show debugcount"
help="It will show enable core">
<DETAIL>
Enable core.
</DETAIL>
<PARAM name="module-name"
help="Specify the module name i.e. enable or disable"
ptype="STRING"/>
<ACTION>c_file.c 3 ${module-name}</ACTION>
</COMMAND>
As I mentioned that I want auto complete of a statement so the parametere i.e.
${modulename}
will be either enable or disable so I want if user press e and tab then automatically enable should come or if user press d and tab then automatically disable should be come.
And about macros as you can see in tag I am passing value i.e.
<ACTION>c_file.c 1</ACTION>
to my c file but instead of value I want to use some variable name or macro so it would be something like
<ACTION>c_file ${var} ${modulename}</ACTION>
where $var=1
After lot of research finally I successfully implemented auto completion of command.
Like in my example I want user to enter enable or disable in command line. This can be achieved by the following xml file. Just we had to use VAR tag in xml file and same for macros.
<?xml version="1.0" encoding="UTF-8"?>
<CLISH_MODULE xmlns="http://clish.sourceforge.net/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://clish.sourceforge.net/XMLSchema
http://clish.sourceforge.net/XMLSchema/clish.xsd">
<!--=======================================================-->
<COMMAND name="show"
help="some utility commands for show"/>
<COMMAND name="show connection"
help="Show the connection">
<DETAIL>
connection status
</DETAIL>
<ACTION>c_file.c 1</ACTION>
</COMMAND>
<COMMAND name="show debugcount"
help="It will show enable core">
<DETAIL>
Enable core.
</DETAIL>
<PARAM name="module-name"
help="Specify the module name i.e. enable or disable"
ptype="STRING"
completion="${third_par}"/>
<ACTION>c_file.c 3 ${module-name}</ACTION>
<VAR name="third_par" help="enable/disable" value="enable disable"/>
</COMMAND>
About completion. There are several ways to implement it.
The first way is something like this:
<PARAM name="module-name"
help="Specify the module name i.e. enable or disable"
ptype="STRING"
completion="enable disable"/>
It's simple but not strict i.e. user can type something else than "enable/disable".
The second way is PTYPE with method="select":
<PTYPE name="BOOL" method="select" pattern="true(1) false(0)" help="Boolean choice"/>
This way is strict. Autocompletion will show "true/false" but user will get corresponding PARAM with values "1/0" in ACTION. But you can use pattern="true(true) false(false)" to get "true" or "false" in ACTION.
The third way is switch:
<PARAM name="choose" help="switch example" mode="switch" ptype="SWITCH">
<PARAM name="enable" help="Enable" ptype="SUBCOMMAND" mode="subcommand"/>
<PARAM name="disable" help="Disable" ptype="SUBCOMMAND" mode="subcommand"/>
</PARAM>
It's strict. The user must choose (enter) only one of PARAMs inside "switch" PARAM.
About VARs... The VARs in klish is global. So it can appear without COMMAND tag or VIEW tag. Put it on the same level as "VIEW" tag.
I am not sure if the above XML is well-formed. It seems that in the current clish.xsd schema the <VAR> element is no longer valid to be under the <COMMAND> element. In fact, the <VAR> element has no valid place at all.
To verify: xmllint -schema /path/to/latest/clish.xsd --noout /path/to/your/file.xml
You will notice that the presence of the <VAR> will invalidate the XML against the schema.
Below is the <COMMAND> element schema:
<xs:complexType name="command_t">
<xs:sequence>
<xs:element ref="DETAIL" minOccurs="0"/>
<xs:element ref="PARAM" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="CONFIG" minOccurs="0"/>
<xs:element ref="ACTION" minOccurs="0"/>
</xs:sequence>
<xs:attributeGroup ref="menu_item_g"/>
<xs:attribute name="ref" type="xs:string" use="optional"/>
<xs:attribute name="view" type="xs:string" use="optional"/>
<xs:attribute name="viewid" type="xs:string" use="optional"/>
<xs:attribute name="access" type="xs:string" use="optional"/>
<xs:attribute name="args" type="xs:string" use="optional"/>
<xs:attribute name="args_help" type="xs:string" use="optional"/>
<xs:attribute name="escape_chars" type="xs:string"
use="optional"/>
<xs:attribute name="lock" type="bool_t" use="optional"
default="true"/>
<xs:attribute name="interrupt" type="bool_t" use="optional"
default="false"/>
</xs:complexType>
Basically, specifying that inside COMMAND should be in order the following:
DETAIL
PARAM
CONFIG
ACTION
So if you place DETAIL after PARAM, it is invalid against the schema. I am referring to the following clish.xsd schema version in klish git repo:
Author: Serj Kalichev <serj.kalichev#gmail.com>
Date: Fri Dec 15 18:03:53 2017 +0300
Version 2.1.4
Related
Using cxf-rt-frontend-jaxws 3.1.8 with jaxb-impl 2.1.13. Using cxf-rt-frontend-jaxws in pom.xml. If I use any version higher than 2.1.13 the wsdl generated is different which causes clients to send soap messages in which elements are assigned wrong namespaces
WSDL definition that work (jaxb-impl 2.2.13). See CaseCourt definition
<xs:complexType name="QueryMessageType">
<xs:complexContent>
<xs:extension base="ns3:ComplexObjectType">
<xs:sequence>
<xs:element name="SendingMDELocationID" type="ns1:IdentificationType"/>
<xs:element name="SendingMDEProfileCode" type="xs:normalizedString"/>
<xs:element name="QuerySubmitter" type="ns1:EntityType"/>
<xs:element ref="ns4:CaseCourt"
if a higher version of jaxb-impl is used the definitions in the wsdl look like below and the client or SoapUI builds messages with wrong namespaces.
<xs:complexType name="QueryResponseMessageType">
<xs:complexContent>
<xs:extension base="ns4:ComplexObjectType">
<xs:sequence>
<xs:element name="SendingMDELocationID" type="ns1:IdentificationType"/>
<xs:element name="SendingMDEProfileCode" type="xs:normalizedString"/>
<xs:element name="CaseCourt" type="ns3:CourtType"
Any idea how to build the wsdl which uses ref using higher version of jaxb-impl or cxf. Basically com.sun apis work, Jakarta messes up the request message namespaces
tried different things but nothing works.
I have an XSD from a third party that I'm trying to use to create an XML schema collection in SQL Server and validate XML received from that third party.
Upon validation, I receive an error:
XML Validation: Invalid content. Expected element(s): 'element1','element2'. Found: element 'element3' instead. Location: /DOCUMENT[1]/:reference_data[1]/:element3[1].
The relevant XSD and XML look correct to me and I can't determine why this error is occurring. Here is the relevant XSD trimmed back to the relevant elements (the whole document is huge so I won't post here):
<xs:element name="reference_data">
<xs:complexType>
<xs:sequence>
<xs:element name="element1" minOccurs="0" maxOccurs="256">
<xs:complexType>
<xs:simpleContent>
... some other stuff
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="element2" minOccurs="0" maxOccurs="50">
<xs:complexType>
<xs:simpleContent>
... some other stuff
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:choice minOccurs="0" maxOccurs="1000">
<xs:element name="element3" minOccurs="0" maxOccurs="1000">
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
Here is the relevant XML being validated:
<reference_data>
<element1>ABCD</element1>
<element3>
<associated_detail1>whatever</associated_detail1>
<associated_detail2>whatever</associated_detail2>
</element3>
</reference_data>
As you can see, element1 is there, so I don't understand why it found element3 and not element1. Element2 is not there, but it's also defined in the XSD as minoccurs=0, so why is it "expected"?
It is unusual for an XSD validator to issue incorrect validation errors - especially if the XML processor is one of the heavily-used ones (such as the one shipped with a Java VM).
However, if your XSD and XML are exactly as posted then I agree with your assessment. After seeing the first occurrence of /reference_data/element1, the allowed set of 'next tag names' is (element1,element2,element3).
Filburt's comment about the unexpected child elements under element3 is correct, but that should produce a different XSD validation error (one that relates to the content of element3)
I recommend that you re-test with the exact XSD and XML that you posted.
I am using cxf-codegen-plugin v. 3.2.4 in a maven project. WSDL refers to the schema:
<xsd:import namespace="http://mynamespace/"
schemaLocation="../schema/MySchema.xsd"/>
But when the generated Server runs, the published wsdl refers to the schema like this:
<xsd:import namespace="http://mynamespace/" schemaLocation="http://localhost:9999/?xsd=1"/>
And this generated xsd changed the argument names for a given method. The original schema has the following definition:
<xs:complexType name="myMethod">
<xs:sequence>
<xs:element name="messageHeader" type="tns:soapMessageHeader" minOccurs="0"/>
<xs:element name="myId" type="xs:string" minOccurs="0"/>
<xs:element name="mySecondId" type="xs:string" minOccurs="0"/>
<xs:element name="myThirdId" type="xs:string" minOccurs="0"/>
<xs:element name="password" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
Whereas the generated schema has the following:
<xs:complexType name="myMethod">
<xs:sequence>
<xs:element name="arg0" type="tns:soapMessageHeader" minOccurs="0"/>
<xs:element name="arg1" type="xs:string" minOccurs="0"/>
<xs:element name="arg2" type="xs:string" minOccurs="0"/>
<xs:element name="arg3" type="xs:string" minOccurs="0"/>
<xs:element name="arg4" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
It changed the element names from the defined ones to "arg0", "arg...". I need this not to be done.
My pom has this:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${source.wsdl.path}</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/MyServiceDefinition.wsdl</wsdl>
<extraargs>
<extraarg>-impl</extraarg>
<extraarg>-verbose</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
The automatically generated interface for the service has the #WebParam annotation.
Can anyone help me, please?
In http://www.benmccann.com/web-services-tutorial-with-apache-cxf the author indicates the usage of endpointInterface annotation attribute in order to respect the annotations inside the automatically generated interface (by cxf itself):
#WebService(endpointInterface = "com.company.auth.service.AuthService",
serviceName = "corporateAuthService")
This alternative requires no additional xml configuration.
Tomcat EE documentation gives us a completed example: http://tomee.apache.org/examples-trunk/simple-webservice
Yet another stackoverflow question that could be related: jax-ws regarding endpointinterface
I have just figured it out: although the generated interface for the service has the #WebParam annotation, the respective concrete class that implements the EndPoint does not have it. I thought that wouldn't be a problem, since the interface has the annotation. Then I tried to add them to the parameters and voilá! The generated xsd suddenly comes out right and I can read the parameters!
I am still experimenting with the SimpleXML framework. As a first step I am parsing a larger XML file and then immediately emitting it as XML again, i.e. my test-program so far looks like:
Persister serializer = new Persister(new TypeMatcher());
File source = new File(filenameIn);
List myList = serializer.read(List.class, source);
serializer.write(myList, outfile);
This works all fine, however, what I noticed is, that the fields of the List are emitted in the wrong order!
The schema that my List has to follow reads:
<xs:element name="list">
<xs:complexType>
<xs:sequence>
<xs:element name="properties" type="Properties" maxOccurs="1" minOccurs="1" />
<xs:element name="columns" type="Columns" maxOccurs="unbounded" minOccurs="1" />
<xs:element name="items" type="Items" maxOccurs="unbounded" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
When the list is written, however, the sequence that I get is:
<list>
<items>
...
</items>
<properties ...>
...
</properties>
<columns>
...
</columns>
</list>
i.e. the items, which should come last, are emitted first. That causes error on later reading again, since the items refer to data that are define in the columns, which are then still undefined, if that order is not maintained.
M.
For maintaining order on serialization the #Order annotation can be used (see this tutorial).
Also, in the specific context of serializing with simple-framework, Java List does not usually guarantee order, but you can use LinkedList for that matter.
Validation of my XML document fails on Oracle (via oraxsd c library), but succeeds in other tools.
Oracle validation error:
LSX-00009: data missing for type "#simple"
LSX-00213: only 0 occurrences of particle "sequence", minimum is 1
For following XSD:
<xs:element name="AGREE" minOccurs="0">
<xs:simpleType>
<xs:restriction base="type7434"/>
</xs:simpleType>
</xs:element>
<xs:simpleType name="type7434">
<xs:annotation>
<xs:documentation>AGREE</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="70"/>
</xs:restriction>
</xs:simpleType>
And following XML:
<AGREE/>
Same result for:
<AGREE></AGREE>
Is the Oracle validation wrong in this case? If so, what would be the workaround?
I have little control over XSD, some control over XML and full access to validation process itself.
Oracle version: Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit
For what it's worth, it looks like an error to me. I wonder if the validator is making some eccentric distinction between sole tags and empty elements: does it also reject <AGREE></AGREE>? Does it change the behavior if you add <xs:minLength value="0"/> to the declaration of type7434?