samedi 9 mai 2015

there is an error in xml document (2 2) xmlns='' was not expected

The error I am getting is all over stackoverflow answered again and again, I have tried few changes in the code but not able to remove the error. here is the class I am using for serialization and deserialization. Please have a look at it.

I don't understand terms like XMLroot, XML element and namespace. So please answer accordingly, like what namespace should I give, what could be the XML root.

If u can edit it, it would be great:

namespace tudumo9
{

  public class data
  {
    public string project_name;
    public string note_text;
    public string tag_text;
    public DateTime start_date;
    public DateTime due_date;
    public string action;

    public  data(){}

  }
}

My XML:

<?xml version="1.0"?>
<ArrayOfData xmlns:xsi="http://ift.tt/ra1lAU" 
             xmlns:xsd="http://ift.tt/tphNwY">
  <data>
    <project_name>p1</project_name>
    <tag_text>tagged</tag_text>
    <start_date>0001-01-01T00:00:00</start_date>
    <due_date>0001-01-01T00:00:00</due_date>
    <action>Action</action>
  </data>
</ArrayOfData>

Exracting text from xml using R

This is the xml code part that I am working on: I need to extract some specific text from the xml code.

The xml code.

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="CoreNLP-to-HTML.xsl" type="text/xsl"?>
<root>
  <document>    
    <dependencies type="collapsed-dependencies">//the collapsed-dependencies tag
                  <dep type="root">
                    <governor idx="0">ROOT</governor>
                    <dependent idx="8">provide</dependent>
                  </dep>
                  <dep type="mark">
                    <governor idx="2">requested</governor>
                    <dependent idx="1">If</dependent>
                  </dep>
        </dependencies>
    </document>
</root>

I would like the output in the following format:

root(ROOT-0,provide-8)
mark(requested-2,If-1)
advcl(provide-8,requested-2)
case(TD-4,by-3)

I am able to extract each of the parameter separately, but cannot take the whole thing out in one go.

abstracts <- xpathSApply(doc,"//*/dependencies[@type='collapsed-dependencies']",xmlValue) # finds the words within collapdsed-dependencies
abstracts #value
#"ROOTproviderequestedIfproviderequestedTDby"

type <- xpathSApply(doc, "//dependencies/dep", xmlGetAttr, 'type') #gives the types 
type #value
#[1] "root"       "mark"       "advcl"      "case"

idx1 <- xpathSApply(doc, "//dependencies/dep/governor", xmlGetAttr, 'idx') # gives the idx for governor
idx1 #value
#[1] "0"   "2"   "8"   "4"   "2"   "8"

# gives the idx for dependent
idx2 <- xpathSApply(doc, "//dependencies/dep/dependent", xmlGetAttr, 'idx') 

What is the meaning of ProjectTemplate tag in plugin.XML intellij?

I am new to intellij plugin development. I am studying on some plugins from repositories to start my project on developing an IDEA plugin. I need to create a new project wizard which is specific to my plugin. Thus I am using <extentions></extention> tags in plugin.xml. In some projects I went through, had <moduleBuilder> tag within them. But instead I found different tag like this.

 <projectTemplate projectType="MyApplication" templatePath="resources/filename.zip" category="true"/>

In this project there is no any "filename.zip" but works fine. This plugin creates a folder hierarchy after running which is like a template. Please can someone explain me about these tags? What is the difference between <projetTemplate> and <moduleBuilder> which are written within <extention></extention> tags?

iterating through all xml elements python

I have just started out using python (3+) and am trying to figure out how to extract all the elements from an XML file inc all the child nodes (so grand children and great grand children nodes etc if that makes sense) without doing a check after extracting every child. I cannot hardcode, as the xml file may change. I simply would like to extract the element, its parent element and if it has any children.

Any advice/help would be greatly appreciated.

Cap.

Obtain styled attributes for child from parent's style definition

The question title is probably nonsensical. I am creating a bunch of custom views that will be placed in a single parent layout - a custom FrameLayout.

These custom views have their own style attr which are set using the parent's style attr.

As an example, consider Parent to be the custom FrameLayout. Its style attr is defined in attrs.xml:

<attr name="parentStyleAttr" format="reference" />

The Child also has its attr:

<attr name="childStyleAttr" format="reference" />

And Parent defines its styleable attr as:

<declare-styleable name="Parent">
    <attr name="childStyleAttr" />
</declare-styleable>

Child's styleable attr:

<declare-styleable name="Child">
    <attr name="childBgColor" format="color" />
</declare-styleable>

Following this, I define a style for the parent:

<style name="ParentStyle">
    <item name="childStyleAttr">@style/ChildStyle</item>
</style>

and one for Child:

<style name="ChildStyle">
    <item name="childBgColor">@color/blah</item>
</style>

For Parent, I set up parentStyleAttr in the app's theme:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="parentStyleAttr">@style/ParentStyle</item>
</style>

Now, when Parent is created, it inflates a layout containing Child:

LayoutInflater.from(getContext()).inflate(R.layout.child, this, true);

During Child's initialization, I need to read the value of the style attribute set in @style/ChildStyle - childBgColor.

This doesn't work:

final TypedArray a = context.obtainStyledAttributes(attrs,
          R.styleable.Child, R.attr.childStyleAttr, R.style.ChildStyle);

The way I am currently reading attr/childBgColor is:

public Child(Context context, AttributeSet attrs, int defStyleAttr) {
    super(createThemeWrapper(context), attrs, defStyleAttr);
    initialize(attrs, defStyleAttr, R.style.ChildStyle);
}

private static ContextThemeWrapper createThemeWrapper(Context context) {
    final TypedArray forParent = context.obtainStyledAttributes(
            new int[]{ R.attr.parentStyleAttr });
    int parentStyle = forParent.getResourceId(0, R.style.ParentStyle);
    forParent.recycle();

    TypedArray forChild = context.obtainStyledAttributes(parentStyle,
            new int[]{ R.attr.childStyleAttr });
    int childStyleId = forChild.getResourceId(0, R.style.ChildStyle);
    forChild.recycle();

    return new ContextThemeWrapper(context, childStyleId);
}

void initialize(AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    Context context = getContext();
    final Resources res = getResources();

    final TypedArray a = context.obtainStyledAttributes(R.styleable.Child);

    ....
}

I am not confident if this is the right approach. Can someone help shed some some light on this?

Run activity only once, then always run the main one

As the title says, Scenario is: On first time using the app, Show Screen A. Once you are done with screen A, the button will lead to you Screen B. From now on and forever, the Screen B will always be main "Screen"(Activity?) when you start the app. I am trying this 2 days and i can't get it. Somebody please explain a little detailed, or even better throw me a code.rar so i can research it. I'm going crazy with this!!!

Looking for advice on storing, reading, and dynamically updating data in XML file (C#)

I'm a bit of a newbie to C# and I've never done anything with XML. Most of my experience is C code written for microcontrollers, with some C/C++ and linux scripting experience, but never any XML.

Basically, I've got a bunch of firmware update files in a folder, currently about 50, but users could have as many as a hundred or more, especially if they don't delete old versions or the program gets expanded to support additional hardware. My program needs to check all those files, parse a little data out of them, and store it in some fashion for quick lookup. I thought about just doing a CSV file, but figured I might as well learn a little about XML in the process.

My first problem is formatting the data. One firmware file may cover multiple hardware models, and there can be multiple versions of the firmware for one model. When the program starts, it will need to make a list of all the file names currently in the XML file and compare them to those in the folder. Later it will need to find all the files with the right model name. I've come up with a couple different formats for storing the data, I'm currently leaning towards option 2, but I'd really appreciate an expert opinion.

Option 1:

<Model model="Model String">
    <FirmwareFile filename=foo.bar> 
        <Version> "1.2.3" </Version>
        <DateCode> "05082015" </DateCode>
    </FirmwareFile>
    <FirmwareFile filename=foo2.bar>
        [...]
    </FirmwareFile>
</Model>

Option 2:

<FirmwareFile filename=foo.bar> 
    <Models>"Model A", "Model B"</Models> //probably not the right way to do this
    <Version> "1.2.3" </Version>
    <DateCode> "05082015" </DateCode>
</FirmwareFile>

The other problem is which library and which method of retrieving the data would be best. The way I see it, I have two options for working with the file, either I read through it on the disk twice (the first time reading file names, the second time to look up model numbers) and write/delete entries from it directly, or else I read all the data once into memory (probably a list of a class), and if anything changes rewrite the file. Which way should I be going? And which library should I be using?

Thanks!

How to Modified or permanently delete Field in the DBGrid with Delphi?

how so that I can remove / modify fields in the DB Grid permanently? I use this code: NB : CDS = ClientDataSet DBG = DBGrid Database I use is *.xml

uses
  Windows, SysUtils, Forms, ExtCtrls, Buttons, DB, DBClient, DBGrids,
  Grids, Controls, StdCtrls, Dialogs, Classes;

type
  TForm1 = class(TForm)
        B2: TSpeedButton;
        B3: TSpeedButton;
        DS: TDataSource;
        CDS: TClientDataSet;
        DBG: TDBGrid;
        SD: TSaveDialog;
        RG: TRadioGroup;
        E1: TEdit;
        E2: TEdit;
        L1: TLabel;
        L2: TLabel;
        B1: TSpeedButton;
        B4: TSpeedButton;
        B5: TSpeedButton;
        OD: TOpenDialog;
    var
        FN, FDragOfs: Integer;
        FDragging: Boolean;

    procedure TForm1.FormShow(Sender: TObject);
    begin
       FN := 1;
       RG.ItemIndex := 0;
    end;

    on Button Create --->

    try
       FN := FN + 1;
       CDS.Active := false;
    with CDS.FieldDefs.AddFieldDef do
    begin
       Name := E1.Text;
    case RG.ItemIndex of
       0 :
    begin
       DataType := ftString;
       Size := StrToInt(E2.Text);
    end;
       1 :
       DataType := ftInteger;
    end;

    end;
       CDS.CreateDataSet;
       E1.Text := 'Field'+IntToStr(FN);
       RG.ItemIndex :=0;
    finally
       CDS.Active := True;
    end;

    on Button Export To File ---->

    if not SD.Execute then
       exit
    else
    begin
       CDS.SaveToFile(SD.filename,dfxml);
       CDS.Active := false;
       CDS.FileName := SD.FileName;

    on Button Delete --->

        CDS.Fields.Remove (DBG.Columns.Items [DBG.SelectedIndex] .Field);
        //DBG.Columns.Delete(DBG.SelectedIndex);
        DBG.Columns.RebuildColumns;

    DB Structur e.g like this : 

        <?xml version="1.0" standalone="yes"?> 
         <DATAPACKET Version="2.0">
        <METADATA>
        <FIELDS>
        <FIELD attrname="Number" fieldtype="i4"/>
        <FIELD attrname="Date" fieldtype="string" WIDTH="20"/>
        <FIELD attrname="Name" fieldtype="string" WIDTH="20"/>
        <FIELD attrname="Phone" fieldtype="string" WIDTH="20"/>
        <FIELD attrname="Address" fieldtype="string" WIDTH="20"/>
        <FIELD attrname="Manager" fieldtype="string" WIDTH="20"/>
        </FIELDS>
        <PARAMS/>
        </METADATA>
        <ROWDATA>
        </ROWDATA>
        </DATAPACKET>

so the question of how way I can remove / replace(rename or modified) with another name field that I do not want when Run-Time, i want to delete this line. example:

<FIELD attrname = "Date" fieldtype = "string" WIDTH = "20" />

after I remove Field does not appear, but when I took my application and re-run the database load sa'at back again as before.

sorry about my English.

Android Manifest mismatched tag

i've been trying to open an existing Android project but i get an error on its Android Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://ift.tt/nIICcg"
package="com.one.piano"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
    android:minSdkVersion="9"
    android:targetSdkVersion="17" />

<application

    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.evilduck.piano.PianoDemoActivity"
        android:label="@string/app_name" />
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

The error is:

Error:(25, -1) Android Resource Packaging: [custom_view_keyboard-master] C:\Users\user\Desktop\oneapp.idea\AndroidManifest.xml:25: error: Error parsing XML: mismatched tag

which seems to be on the last "activity" on the previous line of the last.

Any ideas?

How to write Xpath

This is the HTML in tabular format.

<tr><td style="width: 150px;">Development Name:</td><td><b>Bellewoods</b></td></tr>

<tr><td style="width: 150px;">Property Type:</td><td><b>Executive Condominium</b></td></tr>

<tr><td style="width: 150px;">Developer:</td><td><b>Qingjian Realty (Woodlands) Pte Ltd</b></td></tr>
                                                                                        <tr><td style="width: 150px;">Tenure:</td><td><b>99-year Leasehold</b></td></tr>
                                                                                            <tr><td style="width: 150px;"># of Floors:</td><td><b>30</b></td></tr>

<tr><td style="width: 150px;"># of Units:</td><td><b>561</b></td></tr>

I want to extract:-

Development Name Property Type Developer Tenure Floors Units

I am using this xpath, but its not working . Please help

'//tr//td[@style="width: 150px;" and text()="Development Name:"]//td//b'

Parsing option and optgroup in XML with PHP

I have an xml file that defines form fields. In the case of a list with optgroups, my xml would contain something like

<field
    name="expertise"
    type="multilist"
    label="Area of Expertise"
>
    <option value="Disaster Management">Disaster Management </option>
    <option value="Energy Security">Energy Security </option>
    <optgroup label="Environment">
        <option value="Climate">Climate </option>
        <option value="Resource Security">Resource Security </option>
    </optgroup>
</field>

I am trying to loop through nodes such as

foreach ($feed->fieldset[1]->field[$j]->children() as $c):
    foreach($c->attributes() as $key => $value):
        echo '<'.$c->getName().' '.$key.'="'.$value.'">'.$c.'</'.$c->getName().'><br>';
    endforeach;
endforeach;

I know, probably doesn't make sense for the value to equal the label, but I'll worry about that later.

For now, I am trying to figure out how to loop through both the options and the options within an optgroup. Above loop is not showing the optgroup's options (as expected). Seems I probably have to do some recursion, but was wondering if there are better ways you might recommend, such as existing php xml functions that handle what I am trying to do (so far I have not found anything).

Thanks!

Compare and Merging two XML "STRINGS" in java

I want to compare and merge 2 XML formats in JAVA which is stored as strings. I want to merge the strings and give the output as a single XML format. I want to compare unique IDs in both XML strings and merge each record accordingly.For example if i have product ID, product name, product description in one XML and product ID, number of stocks in the other XML ,I want to compare product IDs in both XML and if they are same, then I want output in the format which has: product ID, product name, product description, number of stocks for each record.Please guide me with a sample code for this in Java. There shouldn't be any loop statement for this comparing and merging.

WPF trigger event by clicking on specified content of SelectedItem in ListBox

I have template for ListBoxItems that contains 3 columns. Each item is represented by picture-text-picture. Is there some posibillity how to trigger event (for example PreviewMouseLeftButtonDown) only by clicking on third column in ListBoxItem (not enywhere else on item).

I know how to trigger it by clicking on whole ListBoxItem, but i need it to trigger only when clicked on the last column (picture). Thanks.

<ListBox.ItemTemplate>
 <DataTemplate>
   <Grid Margin="0,4,0,4">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="20" />
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="20" />
       </Grid.ColumnDefinitions>
       <Image Source="images/showFile.png" Grid.Column="0" Height="16" Width="16"/>
       <TextBlock Text="{Binding Name}" Grid.Column="1"/>
       <Image Source="images/delete.png" Grid.Column="2" Height="16" Width="16"/>                        
  </Grid>
 </DataTemplate>
</ListBox.ItemTemplate>   

JAXB support for SOAP style arrayType

I'm trying to make a new version of a server that previously used Axis 1.4 to respond to SOAP RPC requests using Spring-WS. I have a few of the RPC calls working, but I'm stuck trying to satisfy a request that expects a SOAP body that looks like this:

<rpcCallResponse soapenv:encodingStyle="http://ift.tt/wEYywg">
   <responseElement soapenc:arrayType="xsd:string[5]" 
        xsi:type="soapenc:Array" 
        xmlns:soapenc="http://ift.tt/wEYywg">
      <responseElement xsi:type="xsd:string">val1</responseElement>
      <responseElement xsi:type="xsd:string">val2</responseElement>
      <responseElement xsi:type="xsd:string">val3</responseElement>
      <responseElement xsi:type="xsd:string" xsi:nil="true"/>
      <responseElement xsi:type="xsd:string" xsi:nil="true"/>
   </responseElement>
</rpcCallResponse>

I'm struggling to write the XML schema for this, and to get the JAXB marshaller to shove the xsi:type annotations into the response.

What's the correct XML schema to use/set of annotations to use to get this to marhsal (Java -> XML) correctly?

Cannot resolve definition within WSDL in eclipse, possible eclipse import error?

After initially loading a completed project into eclipse for a change I'm getting an error on 3 components within a contained WSDL.

Error

"src-resolve: Cannot resolve the name 'tns:AEExceptionBO' to a(n) 'type >definition' component."


The three elements
*submitCallFault1_submitCallFault
*getOutageStatusFault1_getOutageStatusFault
*getOutageCircuitFault1_getOutageCircuitFault

As far as I can tell the import that currently exists (line 8 of wsdl) should load the xsd file correctly, no other errors exist in the project. Does anyone know why eclipse isn't able to process this wsdl?

WSDL (relevant parts)

<wsdl:definitions name="AEAdmsAecServiceDelegate"
    targetNamespace="http://ift.tt/1KToYXY"
    xmlns:tns="http://ift.tt/1KToYXY" 
    xmlns:wsdl="http://ift.tt/LcBaVt"
    xmlns:xsd="http://ift.tt/tphNwY">
    <wsdl:types>
        <xsd:schema targetNamespace="http://ift.tt/1KToYXY">
            <xsd:import namespace="http://ift.tt/1KToYY0"
                schemaLocation="wsdl/AEAdmsAecService/AEExceptionBO.xsd" />
            <xsd:element name="submitCallFault1_submitCallFault"
                nillable="true" type="bons0:AEExceptionBO" />
            <xsd:element name="getOutageStatusFault1_getOutageStatusFault"
                nillable="true" type="bons0:AEExceptionBO" />
            <xsd:element name="getOutageCircuitFault1_getOutageCircuitFault"
                nillable="true" type="bons0:AEExceptionBO" />
         </xsd:schema targetNamespace>

XSD (in a subdirectory, imported by the WSDL)

<xsd:schema targetNamespace="http://ift.tt/1KToYY0"
    xmlns:bons0="http://ift.tt/1KToYY0"
    xmlns:xsd="http://ift.tt/tphNwY">
    <xsd:include schemaLocation="NameValueBO.xsd" />
    <xsd:complexType name="AEExceptionBO">
        <xsd:sequence>
            <xsd:element minOccurs="1" name="appName" type="xsd:string" />
            <xsd:element minOccurs="0" name="moduleName" type="xsd:string" />
            <xsd:element minOccurs="1" name="errorCode" type="xsd:string">
            </xsd:element>
            <xsd:element minOccurs="1" name="message" type="xsd:string" />
            <xsd:element minOccurs="1" name="exceptionTime" type="xsd:dateTime">
            </xsd:element>
            <xsd:element maxOccurs="unbounded" minOccurs="0" name="nameValues"
                type="bons0:NameValueBO">
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>

Irrelevant parts of the WSDL and other loaded xsd files have been omitted.

C# - ListView to XML with a SaveFileDialog

I am currently making a WinForms application where I have a ListView with a bunch of items. The columns are: Name, World, Vocation, Level and Status.

I want to save these to an XML file in this format:

<ArrayOfPerson>
    <Person>
        <Name>Bobby</Name>
        <World>Earth</World>
        <Vocation>Blabla</Vocation>
        <Level>Blablabla</Level>
        <Status>Online</Status>
    </Person>
    <Person>
        <Name>Jeff</Name>
        <World>Uranus</World>
        <Vocation>Blabla</Vocation>
        <Level>Blablabla</Level>
        <Status>Offline</Status>
    </Person>
</ArrayOfPerson>

And then also be able to load it into the ListView.

My current code looks like this and just saves to a file name "list.xml" in the same folder. Also, the file only outputs it in one line. Instead of nice lines in the XML file (easy to read) it is all mashed together on 1 or 2 lines, which can be quite difficult if I'd want to open the XML file in an editor.

How can I:

  1. Use a SaveFileDialog and choose filename for this

  2. Put 1 element on each line in the XML file, and not all together

  3. Add a OpenFileDialog and load each person into the list again

    public class Person { public string Name { get; set; } public string World { get; set; } public string Vocation { get; set; } public string Level { get; set; } public string Status { get; set; } }

    private void saveListToolStripMenuItem_Click(object sender, EventArgs e)
    {
        List<Person> people = new List<Person>();
        for (int i=0; i<characterList.Items.Count; i++)
        {
            string nameSave = characterList.Items[i].SubItems[0].Text;
            string worldSave = characterList.Items[i].SubItems[1].Text;
            string vocationSave = characterList.Items[i].SubItems[2].Text;
            string levelSave = characterList.Items[i].SubItems[3].Text;
            string statusSave = characterList.Items[i].SubItems[4].Text;
    
            people.Add(new Person { Name = nameSave, World = worldSave, Vocation = vocationSave, Level = levelSave, Status = statusSave });
        }
    
        using (var writer = XmlWriter.Create("list.xml"))
        {
            var serializer = new XmlSerializer(typeof(List<Person>));
            serializer.Serialize(writer, people);
        }
    
    }
    
    

I also provide a screenshot of how the list looks: enter image description here

SOAP service response cannot be mapped

This problem has had me stumped for almost two days now, I really need some help figuring it out.

I have used wsimport to generate code from two different .wsdl files for a Java project.

The first service works just fine but for some reason the response from the second service cannot be unmarshalled to a response object.

Working service:

@WebMethod(action = "[actionName]")
@WebResult(name = "getSimpleCompanyInfoResponse", partName = "getSimpleCompanyInfoResponse")
public GetSimpleCompanyInfoResponse getSimpleCompanyInfo(
        @WebParam(name = "getSimpleCompanyInfoRequest", partName = "getSimpleCompanyInfoRequest") GetSimpleCompanyInfoRequest getSimpleCompanyInfoRequest);

Response POJO:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "getSimpleCompanyInfoResponse", propOrder = {
    //variables
})
public class GetSimpleCompanyInfoResponse {
    //variables
}

Response XML:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://ift.tt/sVJIaE" xmlns:ns1="[namespaceUri]" xmlns:xsi="http://ift.tt/ra1lAU">
    <SOAP-ENV:Body>
        <ns1:getSimpleCompanyInfoResponse>
            <getSimpleCompanyInfoResponse>
                //variables
            </getSimpleCompanyInfoResponse>
        </ns1:getSimpleCompanyInfoResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

NOT working service:

@WebMethod(operationName = "PersonnelInfo", action = "[actionName]")
@WebResult(name = "PersonnelInfoResponse", partName = "PersonnelInfoResponse")
public PersonnelInfoResponse personnelInfo(
@WebParam(name = "PersonnelInfoRequest", partName = "PersonnelInfoRequest") PersonnelInfoRequest personnelInfoRequest);

Response POJO:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "PersonnelInfoResponse", propOrder = {
    //variables
})
public class PersonnelInfoResponse {
    //variables
}

Response XML:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://ift.tt/sVJIaE" xmlns:ns1="[namespaceUri]" xmlns:xsi="http://ift.tt/ra1lAU">
    <SOAP-ENV:Body>
        <ns1:PersonnelInfoResponse>
            //variables
        </ns1:PersonnelInfoResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Using -Dcom.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump=true or monitoring with Wireshark I can see the Response envelope from the second service coming through just fine and unmarshalling doesn't throw any exceptions but in the end PersonnelInfoResponse is null.

The only difference I can see is that the second service response payload in the XML is missing the outer element which seems to be the problem. However, I do not know how to "fix" it so it doesn't look for the outer element.

If anything was unclear or missing please let me know and I'll try to give you all the information.

EDIT:

No, I unfortunately don't have any control over the service itself, I only have the .wsdl and .xsd.

I'm calling the service like this:

ReportsControllerPortType port = new ReportsControllerService().getReportsControllerPort();

PersonnelInfoRequest request = new PersonnelInfoRequest();
//fill the required fields in the request, username, password, etc.

PersonnelInfoResponse response = port.personnelInfo(request);

The client-side service stubs (ReportsControllerService & ReportsControllerPortType) are also automatically generated by wsimport according to the .wsdl and .xsd.

EDIT 2:

Removing the operation name doesn't work, the service fails to initialize. Following are the definitions from both .wsdl-s:

Working service:

<wsdl:message name="getSimpleCompanyInfoRequest">
    <wsdl:part name="getSimpleCompanyInfoRequest" type="tns:getSimpleCompanyInfoRequest" />
</wsdl:message>
<wsdl:message name="getSimpleCompanyInfoResponse">
    <wsdl:part name="getSimpleCompanyInfoResponse" type="tns:getSimpleCompanyInfoResponse" />
</wsdl:message>

<wsdl:portType name="MonitoringControllerPortType">
    <wsdl:operation name="getSimpleCompanyInfo">
        <wsdl:input message="tns:getSimpleCompanyInfoRequest" />
        <wsdl:output message="tns:getSimpleCompanyInfoResponse" />
    </wsdl:operation>
</wsdl:portType>

<wsdl:binding name="MonitoringControllerBinding" type="tns:MonitoringControllerPortType">
    <soap:binding style="rpc" transport="http://ift.tt/LcBaVu" />

    <wsdl:operation name="getSimpleCompanyInfo">
        <soap:operation soapAction="[domain]/#getSimpleCompanyInfo" style="rpc" />
        <wsdl:input>
            <soap:body use="literal" namespace="[namespaceUri]" />
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal" namespace="[namespaceUri]" />
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>

<wsdl:service name="MonitoringControllerService">
    <wsdl:port name="MonitoringControllerPort" binding="tns:MonitoringControllerBinding">
        <soap:address location="[serviceUri]" />
    </wsdl:port>
</wsdl:service>

Not working service:

<wsdl:message name="PersonnelInfoRequest">
    <wsdl:part name="PersonnelInfoRequest" type="tns:PersonnelInfoRequest" />
</wsdl:message>
<wsdl:message name="PersonnelInfoResponse">
    <wsdl:part name="PersonnelInfoResponse" type="tns:PersonnelInfoResponse" />
</wsdl:message>

<wsdl:portType name="ReportsControllerPortType">
    <wsdl:operation name="PersonnelInfo">
        <wsdl:input message="tns:PersonnelInfoRequest" />
        <wsdl:output message="tns:PersonnelInfoResponse" />
    </wsdl:operation>
</wsdl:portType>

<wsdl:binding name="ReportsControllerBinding" type="tns:ReportsControllerPortType">
    <soap:binding style="rpc" transport="http://ift.tt/LcBaVu" />
    <wsdl:operation name="PersonnelInfo">
        <soap:operation soapAction="[domain]/#PersonnelInfo" style="rpc" />
        <wsdl:input>
            <soap:body use="literal" namespace="[namespaceUri]" />
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal" namespace="[namespaceUri]" />
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>

<wsdl:service name="ReportsControllerService">
    <wsdl:port name="ReportsControllerPort" binding="tns:ReportsControllerBinding">
        <soap:address location="[serviceUri]" />
    </wsdl:port>
</wsdl:service>

EDIT 3:

ReportsControllerService and MonitoringControllerService extend javax.xml.ws.Service and contain the definitions of the .wsdl schema location and namespace used. The service class returns a PortType object as you can see:

/**
 * This class was generated by the JAX-WS RI. JAX-WS RI 2.2.9-b130926.1035 Generated source version: 2.2
 */
@WebServiceClient(name = "ReportsControllerService", targetNamespace = "[namespaceUri]", wsdlLocation = "[wsdlUri]")
public class ReportsControllerService extends Service {

    @WebEndpoint(name = "ReportsControllerPort")
    public ReportsControllerPortType getReportsControllerPort() {
        return super.getPort(new QName("[namespaceUri]", "ReportsControllerPort"), ReportsControllerPortType.class);
    }
}

ReportsControllerPortType is an interface which contains methods for every operation endpoint that exists in the service

/**
 * This class was generated by the JAX-WS RI. JAX-WS RI 2.2.9-b130926.1035 Generated source version: 2.2
 */
@WebService(name = "ReportsControllerPortType", targetNamespace = "[namespaceUri]")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@XmlSeeAlso({ObjectFactory.class})
public interface ReportsControllerPortType {

    @WebMethod(operationName = "PersonnelInfo", action = "[actionName]")
    @WebResult(name = "PersonnelInfoResponse", partName = "PersonnelInfoResponse")
    public PersonnelInfoResponse personnelInfo(
        @WebParam(name = "PersonnelInfoRequest", partName = "PersonnelInfoRequest") PersonnelInfoRequest personnelInfoRequest);
    }
}

The thing is, all of those classes are automatically generated by JAX-WS (as you can see from the comments) based on the .wsdl schema. The implementation is abstracted somewhere inside the JDK and I don't have control over that either. Yes, I can refactor the code so I bypass JAX-WS but as I understand it, this is supposed to be like a de facto standard way to consume .wsdl-based SOAP services.

The project uses Spring as a base-framework and I have already confirmed both services will work when I use Spring-WS instead so I can refactor but I want to understand why this way isn't working.

PHP Append XML document with namespaces

I'm trying to parse docx files in PHP. Now I want to append document.xml file (that is main part of unzipped docx file). The structure is:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <w:document xmlns:wpc="http://ift.tt/JiuBoL"
xmlns:mc="http://ift.tt/pzd6Lm"                               xmlns:w="http://ift.tt/JiuBoE"             
mc:Ignorable="w14 wp14">
        <w:body>
            <w:p w:rsidR="00080C51" w:rsidRDefault="00080C51">
                <w:pPr>
                    <w:pStyle w:val="a3"/>
                    <w:ind w:left="1020"/>
                    <w:rPr>
                        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
                        <w:sz w:val="22"/>
                        <w:szCs w:val="22"/>
                    </w:rPr>
                </w:pPr>
                <w:bookmarkStart w:id="0" w:name="_GoBack"/>
                <w:bookmarkEnd w:id="0"/>
            </w:p>
            <w:sectPr w:rsidR="00080C51">
                <w:pgSz w:w="11906" w:h="16838"/>
                <w:pgMar w:top="850" w:right="850" w:bottom="850" w:left="1417" w:header="708" w:footer="708" w:gutter="0"/>
                <w:cols w:space="708"/>
                <w:docGrid w:linePitch="360"/>
            </w:sectPr>
        </w:body>
    </w:document>

What I want to do is add new child <w:p>some text</w:p> tag to <w:body> tag. How can I do this?

There're a lot of ways to work with XML documents in PHP, like DOM, SimpleXMLElement. But which one can help me achieve this?

Android RadioGroup Cannot resolve symbol getCheckedRadioButtonId

I am new to android. At the moment I am working on some examples in my starter book "Android 5"

In the example I am working there is some code which is not working.

XML:

<RadioGroup
        android:id="@+id/rg_art"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <RadioButton
            android:id="@+id/rb_art_netto"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/txt_netto"
            android:textSize="16dp"
            android:checked="true" />

        <RadioButton
            android:id="@+id/rb_art_brutto"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/txt_brutto"
            android:textSize="16dp" />
    </RadioGroup>

Activity:

package com.example.raven.tax_calc;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioGroup;

public class FormularActivity extends Activity {

    public static final String BETRAG_KEY = "betrag";
    public static final String BETRAG_ART = "art";
    public static final String UST_PROZENT = "ust";

    // Betrag
    public void onClickBerechnen(View button) {
        final EditText txtBetrag = (EditText) findViewById(R.id.edt_betrag);
        final String tmpBetrag = txtBetrag.getText().toString();
        float betrag = 0.0f;
        if(tmpBetrag.length() > 0 ){
            betrag = Float.parseFloat(tmpBetrag);
        }
    }

    // Art des Betrages (Brutto, Netto)
    boolean isNetto = true;
    final RadioGroup rg = (RadioGroup) findViewById(R.id.rg_art);
    switch (rg.getCheckedRadioButtonId()) {
        case R.id.rb_art_netto:
            isNetto = "true";
            break;
        case R.id.rb_art_brutto:
            isNetto = false;
            break;
        default:
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.formular_activity);
    }
}

rg.getCheckedRadioButtonId is red highlighted and mouse-over says "Cannot resolve symbol"

What am I doing wrong? Can't find an mistake :-(

Why my XMLEventWriter don't write anything?

I am trying to make a filter but my XMLStreamWriter object seems not to write anything, even to System.out.

public static void main(String... args) throws FileNotFoundException, XMLStreamException {
    //FileOutputStream outputFile = new FileOutputStream("C:\\Users\\Badescu\\Desktop\\outFile.xml");
    XMLOutputFactory outputFactory =  XMLOutputFactory.newInstance();
    XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(System.out);
    //eventWriter = new IndentingXMLEventWriter(eventWriter); // error "IndentingXMLEventWriter cannot be resolved to a type"
    XMLEventFactory eventFactory = XMLEventFactory.newInstance();
    eventWriter.add(eventFactory.createStartDocument());
    eventWriter.add(eventFactory.createStartElement("", "", "a"));
    eventWriter.add(eventFactory.createStartElement("", "", "b"));
    eventWriter.add(eventFactory.createEndElement("", "", "b"));
    eventWriter.add(eventFactory.createEndElement("", "", "a"));
    eventWriter.add(eventFactory.createEndDocument());
}

If I uncomment the line where I've declared the "outputFile" it creates the file but it is empty. The filter that I want to create is the one that can be applied to my previvous question: "Extract specific elements from an input file and write them to an output file using StAX"

SAPUI5 Formatter is not called

I am trying to call a the formatter. e.g. to transform a text to uppercase. I have two formatters, one is in the controller and one is globally in the utils folder.

i tried to call both, but none is called. Can someone help me please :(?

I have a global formatter in utils folder:

jQuery.sap.declare("my.app.util.Formatter");
my.app.util.Formatter = {

    toUpperCase: function(sStr) {
        return sStr.toUpperCase();
    }

};

and one formatter in my controller (i do the require $.sap.require("my.app.util.Formatter"); as well):

myControllerToUpperCaseFormatter : function(sStr) {
  console.log('I WILL DO NOTHING!');
  return sStr.toUpperCase();
}

my XML:

<mvc:View controllerName="my.app.view.XXX"
xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns:l="sap.ui.layout"
xmlns:f="sap.ui.layout.form" xmlns:c="sap.ui.core" xmlns="sap.m">
<Page class="sapUiFioriObjectPage" title="Test">
    <content>

        <Button text="{path: 'MyModel>/name', formatter: 'my.app.util.Formatter.toUpperCase'}"></Button>

        <Button text="{path: 'MyModel>/name', formatter: '.myControllerToUpperCaseFormatter' }"></Button>

    </content>
</Page>

Thanks for the help!

How to remove duplicate span tag in xml twig?

I need to merge span tags with the same style in the following XML document:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<book>
<p><span style="font-size:10pt;">T</span><span style="font-size:10pt;">h</span><span style="font-size:10pt;">e</span></p>
<p><span style="font-style:italic;">o</span><span style="font-style:italic;">f</span><span style="font-size:10pt;">e</span></p>
</book>

My desired output is:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<book>
<p><span style="font-size:10pt;">The</span></p>
<p><span style="font-style:italic;">of</span><span style="font-size:10pt;">e</span></p>
</book>

This is what I have tried so far:

use strict;
use XML::Twig;
my $Document = XML::Twig->new(
        keep_encoding=>1,                                              
        twig_handlers =>{
        },
pretty_print => 'indented',
);
$Document->parsefile("book.xml");
$Document->print();

I am having difficulty understanding the concepts of this module. Is what I am trying to do possible?

Extract specific elements from an input file and write them to an output file using StAX

Let say that I have the next XML:

<?xml version="1.0" encoding="UTF-8"?>
<orders>
     <order created='2002-02-12T11:10:30.000' ID='1233'>
          <fruit>
               <description>Red apples</description>
               <price currency="USD">13.25</price>
               <gardener>John</gardener>
          <fruit>
          <fruit>
               <description>Bananas</description>
               <price currency="USD">11.19</price>
               <gardener>Ana</gardener>
          <fruit>
          <fruit>
               <description>Golden apples</description>
               <price currency="USD">16.46</price>
               <gardener>John</gardener>
          <fruit>
     </order>
     <order created='2002-02-13T15:32:30.000' ID='1234'>
          <fruit>
               <description>Oranges</description>
               <price currency="USD">10.99</price>
               <gardener>Ana</gardener>
          <fruit>
          <fruit>
               <description>Kiwi</description>
               <price currency="USD">10.39</price>
               <gardener>Helen</gardener>
          <fruit>
     </order>
</orders>

And I need to write one XML file for each distinct gradener. (John, Ana, Helen). The name of the xml file should be like gradener_name## where ## are first 2 digits from the value of ID attribute in "order" element (ex. Ana12). Ex. Ana12.xml

<?xml version="1.0" encoding="UTF-8"?>
<fruits>
     <fruit>
          <description>Bananas</description>
          <price currency="USD">11.19</price>
          <gardener>Ana</gardener>
     <fruit>
     <fruit>
          <description>Oranges</description>
          <price currency="USD">10.99</price>
          <gardener>Ana</gardener>
     <fruit>
</fruits>

Here, the fruits are sorted by price. First fruit is the one with higher price.

How to to Open the XML from Database to Windows Form

In SQL table I have XML data. I want to open that XML in windows forms application on Button Click.

   private void button2_Click(object sender, EventArgs e)
    {
        string s = textBox1.Text;
        con.Open();
        SqlCommand cmd1 = new SqlCommand("select XMLfrom XMLTable where ID='" + textBox1.Text + "'", con);
        SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
        con.Close();
        DataSet ds1 = new DataSet();
        da1.Fill(ds1);
        gv_InputXML.AutoGenerateColumns = true;
        gv_InputXML.DataSource = ds1;
    }

When I write this I could not get any thing in DS.

How can I read XML from DB?

Android Studio: Using radioButtons for a quiz

So I'm trying to make an app where you select an answer from a radioButton within a radioGroup, and when you hit the Submit button it will change the textbox to say "Correct" or "Wrong answer", depending on which button was selected. I'm able to run the app, and select the radioButton, but when I click submit, the app crashes and says "Unfortunately, MyApp has stopped".

This is the code that I have:

XML

 <RadioGroup
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/question1"
    android:id="@+id/q1radiobox">

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/q1a1"
            android:id="@+id/q1a1" />
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/q1a2"
            android:id="@+id/q1a2"/>
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/q1a3"
            android:id="@+id/q1a3"/>
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/q1a4"
            android:id="@+id/q1a4"/>
    </RadioGroup>

    <Button
        android:onClick="checkResult"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/q1radiobox"
        android:text="Submit"/>

Java

   private void checkResult() {
      RadioButton rb;
      rb = (RadioButton) findViewById(R.id.q1a3);

      if (rb.isChecked()) {
        ((TextView) findViewById(R.id.answer1)).setText("@string/correct");
      } 
      else {
          ((TextView) findViewById(R.id.answer1)).setText("@string/incorrect");
    }
} 

Any help would be greatly appreciated; I can't work out what's wrong!

Show xml file info into Listview C#

I'm working on a C# Desktop App and in a module I display the info of a xml file into a listview, I coded my solution with Linq to XML like this

string path = "prueba.xml";

            listView1.Items.Clear();
            listView1.Columns.Add(path, 400);

            XElement doc = XElement.Load(path);

            var result = from persona in doc.Elements("persona")
                         select new{
                             nombre = Convert.ToString(persona.Element("nombre").Value).Trim(),
                             ocupacion = Convert.ToString(persona.Element("ocupacion").Value).Trim()
                         };

 foreach (var persona in result)
            {
                /*ListViewItem item = new ListViewItem(persona.nombre);
                item.SubItems.Add(persona.ocupacion);*/

                ListViewItem nombre = new ListViewItem("<nombre>  " + persona.nombre + "  </nombre>");
                ListViewItem ocupacion = new ListViewItem("<ocupacion>  " + persona.ocupacion + "  </ocupacion>");
                listView1.Items.Add("<persona>");
                listView1.Items.Add(nombre);
                listView1.Items.Add(ocupacion);
                listView1.Items.Add("</persona>");
                listView1.Items.Add("");
            }
             }
        }

and it works very fine, as you can see there are items in the listview that represents the nodes of the xml file, but those items are specific for this xml file

<?xml version="1.0" encoding="utf-8" ?>
<personas>
  <persona>
    <nombre>Pablo el primero</nombre>
    <ocupacion>Programador Cliente-Servidor</ocupacion>
  </persona>
  <persona>
    <nombre>Pablo el segundo</nombre>
    <ocupacion>Programador Web</ocupacion>
  </persona>
</personas>  

as you can see in the C# code, it fits for the xml file above but if I retrieve another xml file with different nodes name like for example

<juego>
<juegos>
<name id="ac"> God of War III </name>
...
</juegos>
</juego>

my code wont show me the nodes <juegos>...</juegos> because it will still display the <person>...</person> nodes because it was created to display only the node <person>...</person> so my question: is there a way to show the information of a xml file into a listview using Linq to XML and at the same time display the info as it is coded in the xml file?

I want to know if I can display this format in teh listview:

<?xml version="1.0" encoding="utf-8" ?>
<personas>
  <persona>
    <nombre>Pablo el primero</nombre>
    <ocupacion>Programador Cliente-Servidor</ocupacion>
  </persona>
  <persona>
    <nombre>Pablo el segundo</nombre>
    <ocupacion>Programador Web</ocupacion>
  </persona>
</personas> 

How to specify a duplicate or adjacent XML element in XPath to delete it in xmlStarlet?

I am trying to edit an XML file using xmlStarlet, so I have to specify the element I want to delete in XPath, and I am having problems with the XPath specification. The XML file will contain the following:

<SoundStreamBlock>
   <data>base64 characters</data>
</SoundStreamBlock>
<ShowFrame/>

The problem I have is that, after some previous deletions, I am left with 2 of the ShowFrame elements, one after another, that is, 2 adjacent elements:

<SoundStreamBlock>
   <data>base64 characters</data>
</SoundStreamBlock>
<ShowFrame/>
<ShowFrame/>

I want to delete the duplicate ShowFrame element. Using the following XPath specification in xmlStarlet is not working:

"/swf/Header/tags/ShowFrame/preceding::ShowFrame"

This deletes all of the ShowFrame elements except the last one. I only want to delete the single duplicate ShowFrame element, that is, only when there is a ShowFrame element immediately following a ShowFrame element.

What do I need to add to the XPath spec to restrict it for this adjacent element?

Thanks,

-Andres

XML error message: Extra content at the end of the document

I'm really new to this XML and web world. Please if anyone can help me, I'd really appreciate it. It may just be a minor mistake but I cannot find how to resolve. it. I have written an XML document but I get an error message saying:

This page contains the following errors:

error on line 6 at column 1: Extra content at the end of the document


<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="student_faculty_directory.css"?>
<haccdirectory xmlns:xsi="http://ift.tt/ra1lAU" xsi:schemaLocation="student_faculty_directory_Schema.xsd" />


<haccdirectory> <!--this is where the ERROR occurs-->
<s:student xmlns:s="http://ift.tt/1cz9aOQ">
    <class101>
        <s:name>Austin Tang</s:name>
            <s:info>
                <s:age>28</s:age>
                <s:gender>Male</s:gender>
                <s:major>Web Development</s:major>
                <s:enrollment>SPR12</s:enrollment>
                <s:transferstudent>No</s:transferstudent>
                <s:id>H01179944</s:id>
            </s:info>
        <s:name>Jeremy Riddle</s:name>
            <s:info>
                <s:age>21</s:age>
                <s:gender>Male</s:gender>
                <s:major>Web Design</s:major>
                <s:enrollment>SPR13</s:enrollment>
                <s:transferstudent>Yes</s:transferstudent>
                <s:id>H01539441</s:id>
            </s:info>
        <s:name>Debbie Scissors</s:name>
            <s:info>
                <s:age>19</s:age>
                <s:gender>Male</s:gender>
                <s:major>Web Development</s:major>
                <s:enrollment>FAL14</s:enrollment>
                <s:transferstudent>No</s:transferstudent>
                <s:id>H01570984</s:id>
            </s:info>
        <s:name>Craig Davidson</s:name>
            <s:info>
                <s:age>22</s:age>
                <s:gender>Male</s:gender>
                <s:major>Web Development</s:major>
                <s:enrollment>SPR14</s:enrollment>
                <s:transferstudent>Yes</s:transferstudent>
                <s:id>H01578433</s:id>
            </s:info>
        <s:name>Justin Beer</s:name>
            <s:info>
                <s:age>24</s:age>
                <s:gender>Male</s:gender>
                <s:major>Web Design</s:major>
                <s:enrollment>SPR13</s:enrollment>
                <s:transferstudent>No</s:transferstudent>
                <s:id>H01091349</s:id>
            </s:info>
        <s:name>Melody Herman</s:name>
            <s:info>
                <s:age>19</s:age>
                <s:gender>Female</s:gender>
                <s:major>Web Design</s:major>
                <s:enrollment>SPR12</s:enrollment>
                <s:transferstudent>No</s:transferstudent>
                <s:id>H01992341</s:id>
            </s:info>
    </class101>
</s:student>

<f:faculty xmlns:f="http://ift.tt/1AMA7DW">
    <teacher>
        <f:name>Andre Miller</f:name>
            <f:information>
                <f:age>39</f:age>
                <f:gender>Male</f:gender>
                <f:hiredate>2003-05-23</f:hiredate>
                <f:id>H01908314</f:id>
                <f:campus>Lancaster</f:campus>
            </f:information>
        <f:name>Melody Wright</f:name>
            <f:information>
                <f:age>32</f:age>
                <f:gender>Female</f:gender>
                <f:hiredate>2002-07-12</f:hiredate>
                <f:id>H01809312</f:id>
                <f:campus>Gettysburg</f:campus>
            </f:information>
        <f:name>Andrew Yoder</f:name>
            <f:information>
                <f:age>44</f:age>
                <f:gender>Male</f:gender>
                <f:hiredate>2001-08-12</f:hiredate>
                <f:id>H01782354</f:id>
                <f:campus>Harrisburg</f:campus>
            </f:information>
        <f:name>Heather Miller</f:name>
            <f:information>
                <f:age>50</f:age>
                <f:gender>Female</f:gender>
                <f:hiredate>2001-07-31</f:hiredate>
                <f:id>H01742121</f:id>
                <f:campus>Harrisburg</f:campus>
            </f:information>
        <f:name>Stephanie King</f:name>
            <f:information>
                <f:age>37</f:age>
                <f:gender>Female</f:gender>
                <f:hiredate>2012-09-01</f:hiredate>
                <f:id>H01922111</f:id>
                <f:campus>Lancaster</f:campus>
            </f:information>
        <f:name>Robert Freeman</f:name>
            <f:information>
                <f:age>31</f:age>
                <f:gender>Male</f:gender>
                <f:hiredate>2014-09-10</f:hiredate>
                <f:id>H01801154</f:id>
                <f:campus>Gettysburg</f:campus>
            </f:information>
        <f:name>Casey Stevenson</f:name>
            <f:information>
                <f:age>31</f:age>
                <f:gender>Female</f:gender>
                <f:hiredate>2014-05-30</f:hiredate>
                <f:id>H01642029</f:id>
                <f:campus>Harrisburg</f:campus>
            </f:information>
    </teacher>
</f:faculty>
</haccdirectory>

AppGyver does not run config.xml?

The problem I am encountering is that when I use steroids connect, it runs without the config.xml, and in this file I have many things such as fullscreen mode etc.

How can I make steroids appgyver run the config.xml file?

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.hello" version="0.0.1" xmlns="http://ift.tt/18Fk3Vk" xmlns:cdv="http://ift.tt/1cHnIYX">
    <name>HelloWorld</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <access origin="*" />
    <preference name="phonegap-version" value="3.7.0" />
    <preference name="android-targetSdkVersion" value="19" />
    <preference name="orientation" value="landscape" /><!--No rotation-->
    <preference name="fullscreen" value="true" /><!--Hides the menu on top-->
    <preference name="SplashScreen" value="screen" />
    <preference name="SplashScreenDelay" value="10000" />
</widget>

XML Add multiple variables as one member of an array in C++

Right now, I have an XML file containing data for multiple choice questions for a quiz as seen below. I intend to have lots of questions in here so that the user will get different questions each time they play, which are parsed from the XML file. The quiz itself contains 15 questions each time it is run, so it parses the XML file for questions. Here's an example of the contents of the XML file:

<?xml version="1.0" encoding="utf-8"?>
<questionData>
<question>
<level> 1 </level>
<ref> ref1 </ref>
<questionText>This is a test question using XML!</questionText>
<A>This is A using XML!</A>
<B>This is B using XML!</B>
<C>This is C using XML!</C>
<D>This is D using XML!</D>
<corrAnswer> A </corrAnswer>
<APerc> 97 </APerc>
<BPerc> 1 </BPerc>
<CPerc> 1 </CPerc>
<DPerc> 1 </DPerc>
<PAFAnswer> A </PAFAnswer>
<PAFFeeling> Sure </PAFFeeling>
<FF> B </FF>
<FFcorrPerc> 100 </FFcorrPerc>
<FFwrongPerc> 0 </FFwrongPerc>
<FFPAFAnswer> A </FFPAFAnswer>
<FFPAFFeeling> Sure </FFPAFFeeling>
<EXP> This is a test explanation for the info box. </EXP>
<pronuns> pro-nun-cee-a-sh-un </pronuns>
</question>

<question>
<level> 2 </level>
<ref> ref2 </ref>
<questionText>This is another test question using XML!</questionText>
<A>This is A2 using XML!</A>
<B>This is B2 using XML!</B>
<C>This is C2 using XML!</C>
<D>This is D2 using XML!</D>
<corrAnswer> B </corrAnswer>
<APerc> 96 </APerc>
<BPerc> 1 </BPerc>
<CPerc> 1 </CPerc>
<DPerc> 2 </DPerc>
<PAFAnswer> B </PAFAnswer>
<PAFFeeling> Sure </PAFFeeling>
<FF> A </FF>
<FFcorrPerc> 100 </FFcorrPerc>
<FFwrongPerc> 0 </FFwrongPerc>
<FFPAFAnswer> B </FFPAFAnswer>
<FFPAFFeeling> Sure </FFPAFFeeling>
<EXP> This is another test explanation for the info box. </EXP>
<pronuns> pro-nun-cee-a-sh-un two </pronuns>
</question>

As you can see above, at the moment I have two questions. However, the problem itself doesn't actually reside with the XML file, in fact it resides code-side in C++/CLI. The code I'm using for my parsing function is below:

XmlTextReader^ dataFromQFile = gcnew XmlTextReader("Millionaire\\questionsData.xml");
XmlDocument^ questionsData = gcnew XmlDocument();
questionsData->Load("Millionaire\\questionsData.xml");
XmlNode^ QuestionXML = questionsData->FirstChild;

for each (QuestionXML in questionsData->GetElementsByTagName("question"))
{
    levelFromXML = QuestionXML["level"]->InnerText;
    questionFromXML = QuestionXML["questionText"]->InnerText;
    AFromXML = QuestionXML["A"]->InnerText;
    BFromXML = QuestionXML["B"]->InnerText;
    CFromXML = QuestionXML["C"]->InnerText;
    DFromXML = QuestionXML["D"]->InnerText;
    corrFromXML = QuestionXML["corrAnswer"]->InnerText;
    APercFromXML = QuestionXML["APerc"]->InnerText;
    BPercFromXML = QuestionXML["BPerc"]->InnerText;
    CPercFromXML = QuestionXML["CPerc"]->InnerText;
    DPercFromXML = QuestionXML["DPerc"]->InnerText;
    phoneAnswerFromXML = QuestionXML["PAFAnswer"]->InnerText;
    phoneFeelingFromXML = QuestionXML["PAFFeeling"]->InnerText;
    fiftyAnswer = QuestionXML["FF"]->InnerText;
    fiftyCorrPerc = QuestionXML["FFcorrPerc"]->InnerText;
    fiftyWrongPerc = QuestionXML["FFwrongPerc"]->InnerText;
    fiftyPhoneAnswer = QuestionXML["FFPAFAnswer"]->InnerText;
    fiftyPhoneFeeling = QuestionXML["FFPAFFeeling"]->InnerText;
    exp = QuestionXML["EXP"]->InnerText;
    pronuns = QuestionXML["pronuns"]->InnerText;

    if (Int32::Parse(levelFromXML) == QuestionNo)
    {
        return;
    }

Now, what I'm doing here is parsing the file for all the different elements and storing them in the above variables. For the if statement, I'm saying that if the level tag is equal to the questionNo variable, return the function (this is because the questions get harder the more you progress, so if level = 2 and you're on question 2, load that question and keep the variables to their currents values - a rather cheeky trick) and don't parse the file again. However, obviously this creates a problem. Every time the user answers a question correctly, it has to search for a question that has the same value as questionNo (so if they answered question 2 correctly, questionNo willnow = 3, hence it has to reparse the whole file for a question that has level = 3) Due to the volume of questions there will be, parsing the file every time for a new question at runtime will cause significant backlog in the program while it parses the XML file again. So I came up with the idea of storing all the variable values in one member of an array - which obviously again, causes a problem. My question is, do any of you have a better solution to the aforementioned issue or perhaps have a more efficient way of performing this? I would also appreciate if you could provide some code in context so I have a rough idea of what I'm working with. Thanks.

Xpath to get nodes with distinct values(removing trailing and leading spaces)

I have an XML document in which I am trying to select nodes having distinct values with leading and trailing spaces removed.

I am using following Xpath and it is working:

ROW[COUNTRY[not(text() = following::ROW/COUNTRY[text()])]]

But when I am using normalize-space(text()) in above xpath then the results returned are not correct.

xml sample and xslt used.

How to serialize this class into XML or JSON

I have a list of objects derived from a class named "Campus" which contains two strings, one int and two lists : one for "Students", the other is for "Teachers", before closing the program, I want to save the campus objects and of course the "Student" and "Teachers" objects contained on their lists, I want to serialize those data in an XML or JSON format or even anything else then store the result in a file.

Can somebody give me the fastest way to do the serialization with a library (that is not heavy as boost) in XML or JSON or another solution. When it comes to deal with JSON or XML serialization, I don't know what to do ! EDIT: is this feasible with RapidJSON ?

class Campus
{
private:
    std::string city;
    std::string region;
    int capacity;
    std::list<Student> students;
    std::list<Teacher> teachers;
}

class Student
{
private:
    int ID;
    std::string name;
    std::string surname;
}

class Teacher
{
protected:
    int ID;
    std::string name;
    std::string surname;
};

Encoding odd HTML entities '&lstroke;'

I have problems with some odd HTML entities that comes from a XML file that I have to parse in PHP 5.6.

Some of the HTML entities are:

&lstroke;
n&acute;
a&hook;
e&hook;

The XML comes from CAB Abstracts (http://ift.tt/1doDHIq) and its header is:

<?xml version="1.0" encoding="ISO-8859-1"?>

However, I have tried several encoding systems without success. Also, I have tried using them directly in HTML files, writing them from PHP 5.6 using html_entity_decode like this:

$strings = array('&Sacute;wia&hook;tek', 'Kie&lstroke;kiewicz', 'Zagdan&acute;ska', 'Mie&hook;tkiewski');

foreach ($strings as $s) {
    foreach (array(
            'ISO-8859-1', 'ISO-8859-5', 'ISO-8859-15', 'UTF-8',
            'cp866', 'cp1251', 'cp1252', 'KOI8-R', 'BIG5', 'GB2312',
            'BIG5-HKSCS', 'Shift_JIS', 'EUC-JP', 'MacRoman', '') as $l) {
        print $l . ' ==> ';
        print html_entity_decode($s, ENT_COMPAT | ENT_QUOTES | ENT_XML1 | ENT_XHTML | ENT_HTML5, $l) . '<br>';
    }
}

Nothing works!!

I would like to avoid any kind of solution that include parsing the XML file replacing these entities by the right UTF-8 character. I can not foreseen when odd HTML entities like these will be included and the files are relatively big.

The string should look like these:

Świątek
Kiełkiewicz
Zagdańska 
Miętkiewski

So, the question is:

How can I decode this odd HTML entities to UTF-8 in PHP?

ajout fichier xml a apache et connexion a postgresql

je suis en train de développer une application web,j'ai un fichier File.xml contenant les parametres de connexion a la base de donnée postgre:,,,,,,le quel j'ai ajouté au dossier bin apache.jai une classe de connexion a la base de donné utilisant les données de fichier xml pour se connecter a la base.

toujours en exécutant cette classe j'obtient le message du else? je doute que la classe n'accède pas au File.xml sous le dossier bin d'apache. quoi faire?

private ParamBDD()
{
    SAXBuilder sxb = new SAXBuilder();
    try
    {
        mes_documents mes=new mes_documents();
        Fichier fichier = new Fichier();
        File file=new File("File.xml");

            String str_fichier ="File.xml";


            if (file.isFile())
            {
                org.jdom.Document document = sxb.build(new File(str_fichier));

                Element racine = document.getRootElement();
                List listParam = racine.getChildren("param");

                Iterator i = listParam.iterator();
                while (i.hasNext())
                {
                    Element courant = (Element) i.next();

                    pilote = courant.getChild("pilote").getText().trim();

 else 
JOptionPane.showMessageDialog(null, "le fichier contenant les parametres n'existe pas","",JOptionPane.INFORMATION_MESSAGE);

print xml response separately for each property

I am trying to convert this XML to array this is the response I am getting from API and I want to get the value of statuscode but I am unable to do it.

<?xml version='1.0' encoding='utf-8' standalone='no'?>
<REGISTRATIONRESPONSE>
<STATUSCODE>20</STATUSCODE>
<STATUS>1234</STATUS> 
</REGISTRATIONRESPONSE>

but when i am using the following code

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 6);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,'RequestData='.$post);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded'));
$result = curl_exec($ch);
$resultres=xml2ary($result);
echo '<pre>';
print_r($resultres);

The output is

Array
 (
    [string] => Array
    (
            [_a] => Array
            (
                [xmlns] => http://tempuri.org/
            )
            [_v] => 201234
    )
)

How is the result changing? I have used one more technique also but with that also I am not getting the result that is required

separate xml properties from api response php [duplicate]

This question already has an answer here:

i am getting this xml as a reponse from server

<?xml version='1.0' encoding='utf-8' standalone='no'?><REGISTRATIONRESPONSE><STATUSCODE>20</STATUSCODE><STATUS>1234</STATUS></REGISTRATIONRESPONSE>

i want to retrieve values from this xml if i directly use this string like this i am able to get values separately.

  $xmlString ="<?xml version='1.0' encoding='utf-8' standalone='no'?>
<REGISTRATIONRESPONSE>
<STATUSCODE>20</STATUSCODE>
<STATUS>1234</STATUS>
</REGISTRATIONRESPONSE>";
 $xml = simplexml_load_string($xmlString);
 $array = (array) $xml;
 var_dump($array);
 var_dump($array['STATUSCODE']);
 var_dump($array['STATUS']);

Result Is:

 array(2) {
 ["STATUSCODE"]=>
 string(2) "20"
 ["STATUS"]=>
 string(4) "1234"
  }
 string(2) "20"
 string(4) "1234"

but when i try directly take the response from api like this

   $result =curl_exec($ch);
   print_r($result); 
   echo '<pre>';
   $xml = simplexml_load_string($result);
   $xml = simplexml_load_string($result);
   $array = (array) $xml;
   var_dump($array);
   var_dump($array['STATUSCODE']);
   var_dump($array['STATUS']); 

result which is coming is like this:

   array(1) {
            [0]=>  string(147) "201234"
            }
            NULL
            NULL

I want to get result as i am getting in the 1st case but i can input manually like that every time i want to use variable instead of using xml as a string.

string could not be parsed as xml although url is giving results in xml format on accesing individually

I am having an array of urls which i m accessing with curl api to get the data in exml format ,but some urls out of them are throwing an error that string could not be parsed as xml but when i access that url separately in different file it gives me proper result.But in first file where i m iterating the urls array there is throwing exception on some urls.Code for first file is below.

<?php

function httpGet($url)
{
    $ch = curl_init();  

    curl_setopt($ch,CURLOPT_URL,$url);
 curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
//  curl_setopt($ch,CURLOPT_HEADER, false); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'header-Id:value1',
    'header-Token:value2'
    )); 
    $output=curl_exec($ch); 
    curl_close($ch);
    return $output;
}


function loopData($url){
try {

echo 'looped ';
    $data2 = httpGet($url);

    $xml2 = new SimpleXMLElement($data2);

loopData($xml2->nextUrl);
}
catch(Exception $e){
    var_dump($e);
}
            }


foreach($url as $array){
echo 'new url ';

//echo $array;
loopData($array);

}

?>

If my url array is having 20 urls some urls while iterating throws an exception but when they are accessed separately,the urls gives proper result.

sapui5 fiori xml view how to add the BulletChart

i am coding in fiori (sap web ide) and i have a lack of understanding:

<mvc:View
xmlns="sap.m"
xmlns:core="sap.ui.core"
xmlns:mvc="sap.ui.core.mvc"
xmlns:l="sap.ui.layout"
xmlns:f="sap.ui.layout.form" controllerName="test.view.Detail">
<Page id="detailPage" navButtonPress="onNavBack" title="{i18n&gt;detailTitle}" showNavButton="{device&gt;/isPhone}">
    <content>
        <ObjectHeader id="detailHeader" title="{SelectedOption}" introActive="false" titleActive="false" iconActive="false">
            <customData id="customData3">
                <core:CustomData id="coreCustomData3" key="sapDtResourcePath" value="ClaimingHeader"></core:CustomData>
            </customData>
            <attributes id="detailAttributes">
                <ObjectAttribute id="attribute" text="{i18n&gt;detailText}" active="false"></ObjectAttribute>
            </attributes>
            <firstStatus id="detailStatus">
                <ObjectStatus id="status" text="{SelectedOption}">
                    <customData id="customData4">
                        <core:CustomData id="coreCustomData4" key="sapDtResourcePath" value="ClaimingHeader"></core:CustomData>
                    </customData>
                </ObjectStatus>
            </firstStatus>
        </ObjectHeader>
        <IconTabBar id="idIconTabBar" expanded="{device&gt;/isNoPhone}">
            <customData id="customData5">
                <core:CustomData id="coreCustomData5" key="sapDtResourcePath" value="ClaimingHeader"></core:CustomData>
            </customData>
            <items id="detailsItems">
                <IconTabFilter id="iconTabFilter1" key="selfInfo" icon="sap-icon://calendar">
                    <content>
                        <f:SimpleForm id="iconTabFilter1form" minWidth="1024" editable="false" layout="ResponsiveGridLayout" labelSpanL="3" labelSpanM="3" emptySpanL="4" emptySpanM="4" columnsL="1">
                            <f:content>

at the bottom of the code, i want to include this sample code from sapui5 sdk: Code: Bullet Micro Chart

the problem is, that the code of the BulletChart starts with

<core:View controllerName="sap.suite.ui.commons.sample.BulletChart.BulletChart" xmlns="sap.suite.ui.commons" xmlns:core="sap.ui.core">

my problem is, that it doesnt work, if i add this core:View.. inside of mvc:View.. and/or its the other controller, controllerName="sap.suite.ui.commons.sample.BulletChart.BulletChart, which in want to put inside mvc:view , where there is already a controller.

can someone help me and explain me, how to put this BulletChart at this place?

thanks for help! Screenshot on Imageshack what i want to do @ the link below.

Screenshot on Imageshack what i want to do

Error in web.xml in tomcat v.7.0.61

I get the below error in web.xml near the server-url tag. Below is the web.xml

cvc-complex-type.2.4.a: Invalid content was found starting with element 'servlet-url'. One of '{"http://ift.tt/nSRXKP":url-pattern}' is 
 expected.

Following is the servlet-mapping tag in which the error occurs

<servlet-mapping>
        <servlet-name>appcontroller</servlet-name>
        <servlet-url>/appcontroller</servlet-url>
    </servlet-mapping>

How do i resolve this?

Display simple XML data into an HTML page

i'm sorry if this is a very basic question but i'm really stuck here and i don't have much time. so i created an xml file with data in it and want to display it in html using javascript, but all i get is a blank page. this is my xml file:

<?xml version="1.0" encoding="UTF-8"?>

<text>
    <content>  a random text </content>
</text>

and that's my html file xml

    <script>
        document.write("begin");
        if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera,         Safari
            xmlhttp=new XMLHttpRequest();
        }
        else
        {// code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }

        xmlhttp.open("GET","text.xml",false);
        xmlhttp.send();
        xmlDoc=xmlhttp.responseXML; 

        var x=xmlDoc.getElementsByTagName("text");
        document.write(x[i].getElementsByTagName("content")    [0].childNodes[0].nodeValue);
    </script>

</body>
</html>

maybe it uses httpRequest so it needs a server, but i tried apache and it did not work. thanks for helping me

Deserializing a string XML and error:There is an error in XML document (1, 2)

I need deseriliazing a string XML, but I've a problem.

[XMLRoot]
public class OP
{
    [XmlElement]
    public string Auth;
    [XmlElement]
    public string User;
    [XmlElement]
    public string Password;
    [XmlElement]
    public string Client;
    [XmlElement]
    public string DownloadCode;
    [XmlElement]
    public string PartNumber;
    [XmlElement]
    public int FlexPO;
    [XmlArray]
    public string Terminals;
    [XmlElement]
    public string User;            
}

public void Test()
{
    var serializer = new XmlSerializer(typeof(OP));
    OP result;

    using (TextReader reader = new StringReader(XML))
    {
        result = (OP)serializer.Deserialize(reader);
    }

}

This is code and this is the XML:

<CreateManufactoryOrder xmlns="http://tempuri.org/">
    <op>
        <Auth>
            <User>User</User>
            <Password>Password</Password>
        </Auth>
        <Client>01425787000104</Client>
        <DownloadCode>0460.0001</DownloadCode>
        <PartNumber>M268-773-C4-BRA-3</PartNumber>
        <FlexPO>887614_364</FlexPO>
        <Terminals>
            <String>529-995-835</String>
            <String>529-995-836</String>
            <String>529-995-837</String>
            <String>529-995-838</String>
        </Terminals>
    </op>
</CreateManufactoryOrder>

So, when I debug the code return error: There is an error in XML document (1, 2). I already try change the code in much ways, but nothing did run.

No such external ID currently defined in the system

** No matching record found for external id 'model_oemedical_lab_group' in field 'Object'**

  • i am a beginner in openerp. i was tried to do my own customizations in some simple modules. once i was download the mode called
  • oemedical
  • i can't able to install oemedical_lab.That modul shows some error when i was try to install it.please help me out.I am stuck with this.
  • thanking you

oemedical_lab.py

enter code here
import time

from openerp.osv import fields, orm
 class oemedical_patient (orm.Model):
_name = "oemedical.patient"
_inherit = "oemedical.patient"

_columns = {
    'lab_test_ids': fields.one2many(
        'oemedical.patient.lab.test', 'patient_id', 'Lab Tests Required'),
}

 class test_type (orm.Model):
_name = "oemedical.test_type"
_description = "Type of Lab test"
_columns = {
    'name': fields.char(
        'Test', size=128,
        help="Test type, eg X-Ray, hemogram,biopsy..."),
    'code': fields.char(
        'Code', size=128,
        help="Short name - code for the test"),
    'info': fields.text(
        'Description'),
    'product_id': fields.many2one(
        'product.product', 'Service', required=True),
    'critearea': fields.one2many(
        'oemedical_test.critearea', 'test_type_id', 'Test Cases'),


}
_sql_constraints = [
    ('code_uniq', 'unique (name)', 'The Lab Test code must be unique')]


class lab (orm.Model):
_name = "oemedical.lab"
_description = "Lab Test"
_columns = {
    'name': fields.char(
        'ID', size=128, help="Lab result ID"),
    'test': fields.many2one(
        'oemedical.test_type', 'Test type', help="Lab test type"),
    'patient': fields.many2one(
        'oemedical.patient',
        'Patient',
        help="Patient ID"),
    'pathologist': fields.many2one(
        'oemedical.physician',
        'Pathologist',
        help="Pathologist"),
    'requestor': fields.many2one(
        'oemedical.physician',
        'Physician',
        help="Doctor who requested the test"),
    'results': fields.text(
        'Results'),
    'diagnosis': fields.text(
        'Diagnosis'),
    'critearea': fields.one2many(
        'oemedical_test.critearea', 'oemedical_lab_id', 'Test Cases'),
    'date_requested': fields.datetime(
        'Date requested'),
    'date_analysis': fields.datetime(
        'Date of the Analysis'),
}

_defaults = {
    'date_requested': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
    'date_analysis': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
    'name': lambda self, cr, uid, context: self.pool['ir.sequence'].get(
        cr, uid, 'oemedical.lab'),
}

_sql_constraints = [
    ('id_uniq', 'unique (name)', 'The test ID code must be unique')]


    class oemedical_lab_test_units(orm.Model):
      _name = "oemedical.lab.test.units"
      _columns = {
       'name': fields.char('Unit', size=25),
       'code': fields.char('Code', size=25),
    }
_sql_constraints = [
    ('name_uniq', 'unique(name)', 'The Unit name must be unique')]


   class oemedical_test_critearea(orm.Model):
_name = "oemedical_test.critearea"
_description = "Lab Test Critearea"
_columns = {
    'name': fields.char('Test', size=64),
    'result': fields.text('Result'),
    'normal_range': fields.text('Normal Range'),
    'units': fields.many2one('oemedical.lab.test.units', 'Units'),
    'test_type_id': fields.many2one('oemedical.test_type', 'Test type'),
    'oemedical_lab_id': fields.many2one('oemedical.lab', 'Test Cases'),
    'sequence': fields.integer('Sequence'),
}
_defaults = {
    'sequence': lambda *a: 1,
}
_order = "sequence"


class oemedical_patient_lab_test(orm.Model):
_name = 'oemedical.patient.lab.test'

def _get_default_dr(self, cr, uid, context=None):
    partner_id = self.pool.get('res.partner').search(
        cr, uid, [('user_id', '=', uid)], context=context)
    if partner_id:
        dr_id = self.pool.get('oemedical.physician').search(
            cr, uid, [('name', '=', partner_id[0])], context=context)
        if dr_id:
            return dr_id[0]
        # else:
        #    raise osv.except_osv(_('Error !'),
        #            _('There is no physician defined ' \
        #                    'for current user.'))
    else:
        return False

_columns = {
    'name': fields.many2one(
        'oemedical.test_type', 'Test Type'),
    'date': fields.datetime(
        'Date'),
    'state': fields.selection(
        [('draft', 'Draft'),
         ('tested', 'Tested'),
         ('cancel', 'Cancel')],
        'State', readonly=True),
    'patient_id': fields.many2one(
        'oemedical.patient', 'Patient'),
    'doctor_id': fields.many2one(
        'oemedical.physician',
        'Doctor',
        help="Doctor who Request the lab test."),
    # 'invoice_status' : fields.selection(
    # [('invoiced','Invoiced'),
    # ('tobe','To be Invoiced'),
    # ('no','No Invoice')],'Invoice Status'),
}

_defaults = {
    'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
    'state': lambda *a: 'draft',
    'doctor_id': _get_default_dr,
    # 'invoice_status': lambda *a: 'tobe',
}

oemedical_view.xml

<?xml version="1.0" ?>
<openerp>
<data>

<!-- Lab test units -->
    <record model="ir.ui.view" id="oemedical_lab_unit_form">
        <field name="name">Test Units</field>
        <field name="model">oemedical.lab.test.units</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Test Unit">
                <field name="name" required="1"/>
                <field name="code"/>
            </form>
        </field>
    </record>

    <record model="ir.ui.view" id="oemedical_lab_unit_tree">
        <field name="name">Test Units</field>
        <field name="model">oemedical.lab.test.units</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Test Unit">
                <field name="name"/>
                <field name="code"/>
            </tree>
        </field>
    </record>

    <record model="ir.actions.act_window" id="oemedical_action_lab_unit">
        <field name="name">Lab Testing Units</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">oemedical.lab.test.units</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    </record>

Lab Test Requests oemedical.patient.lab.test form Lab Test Requests oemedical.patient.lab.test tree

    <record model="ir.actions.act_window" id="oemedical_action_lab_test_request">
        <field name="name">Lab Requests</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">oemedical.patient.lab.test</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    </record>

    <menuitem action="oemedical_action_lab_test_request" id="oemedical_labtest_request" parent="oemedical_laboratory_menu"/>

    <record model="ir.actions.act_window" id="oemedical_action_draft_lab_test_request">
        <field name="name">Draft Requests</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">oemedical.patient.lab.test</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="domain">[('state','=','draft')]</field>
    </record>

    <menuitem action="oemedical_action_draft_lab_test_request" id="oemedical_draft_labtest_request" parent="oemedical_labtest_request"/>

    <record model="ir.actions.act_window" id="oemedical_action_today_draft_lab_test_request">
        <field name="name">Today's Draft Requests</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">oemedical.patient.lab.test</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="domain">[('state','=','draft'),('date','&gt;=',time.strftime('%Y-%m-%d 00:00:01')),('date','&lt;=',time.strftime('%Y-%m-%d 23:59:59'))]</field>
    </record>

    <menuitem action="oemedical_action_today_draft_lab_test_request" id="oemedical_today_draft_labtest_request" parent="oemedical_labtest_request"/>


    <record id="view_oemedical_lab_test_filter" model="ir.ui.view">
        <field name="name">Lab Tests Requests</field>
        <field name="model">oemedical.patient.lab.test</field>
        <field name="type">search</field>
        <field name="arch" type="xml">
            <search string="Search Lab Tests Requests">

                <separator orientation="vertical"/>
                    <field name="name" select="1"/>
                    <field name="date" select="1"/>
                    <field name="patient_id" select="1"/>
                    <field name="doctor_id" select="1"/>
                    <field name="state" select="1"/>
                <newline/>

            </search>
        </field>
    </record>

    <record model="ir.ui.view" id="oemedical_patient_view_lab_test">
        <field name="name">Patient Lab Test</field>
        <field name="model">oemedical.patient</field>
        <field name="type">form</field>
        <field name="inherit_id" ref="oemedical.view_oemedical_patient_form"/>
        <field name="arch" type="xml">
            <notebook position="inside">
                <page string="Lab Tests">
                    <field name="lab_test_ids" colspan="4" nolabel="1">
                        <tree string="Lab Tests">
                            <field name="name" required="1"/>
                            <field name="doctor_id"/>
                            <field name="date"/>
                            <field name="state"/>
                        </tree>
                        <form string="Lab Tests">
                            <field name="name"/>
                            <field name="doctor_id"/>
                            <field name="date"/>
                            <field name="state"/>
                        </form>
                    </field>
                </page>
            </notebook>
        </field>
    </record>

            <record model="ir.ui.view" id="oemedical_test_view">
                    <field name="name">Lab test</field>
                    <field name="model">oemedical.test_type</field>
                    <field name="type">form</field>
                    <field name="arch" type="xml">
                            <form string="Lab Test">
                <notebook>
                    <page string="Main Info">
                        <field name="name" required="1"></field>
                        <field name="code"></field>
                        <field name="critearea" colspan="4" nolabel="1">
                <tree string="Test Cases">
                    <field name="sequence"/>
                    <field name="name"/>
                    <field name="normal_range"/>
                    <field name="units"/>
                </tree>
                <form string="Test Cases">
                    <field name="name"/>
                    <field name="units"/>
                    <field name="sequence"/>
                    <newline/>
                    <field name="normal_range"/>
                </form>
            </field>
            <field name="product_id"/>
                    </page>
                    <page string="Extra Info">
                        <field name="info"></field>
                    </page>
                </notebook>
                            </form>
                    </field>
            </record>



            <record model="ir.ui.view" id="oemedical_test_tree">
                    <field name="name">Lab test types list</field>
                    <field name="model">oemedical.test_type</field>
                    <field name="type">tree</field>
                    <field name="arch" type="xml">
                            <tree string='Lab test type'>
                                    <field name="name"></field>
                                    <field name="code"></field>
                            </tree>
                    </field>
            </record>


            <record model="ir.actions.act_window" id="oemedical_action_form_test">
                    <field name="name">New Type of Lab test</field>
                    <field name="type">ir.actions.act_window</field>
                    <field name="res_model">oemedical.test_type</field>
                    <field name="view_type">form</field>
                    <field name="view_id" ref="oemedical_test_view"/>
            </record>

    <record id="view_oemedical_lab_test_type_search" model="ir.ui.view">
        <field name="name">oemedical.test_type.select</field>
        <field name="model">oemedical.test_type</field>
        <field name="type">search</field>
        <field name="arch" type="xml">
            <search string="Search Lab Test Types">

                <separator orientation="vertical"/>
                    <field name="name" select="1"/>
                    <field name="code" select="1"/>
            <newline/>

            </search>
        </field>
    </record>


    <menuitem action="oemedical_action_form_test" id="oemedical_conf_test" parent="oemedical_conf_laboratory" />





            <record model="ir.ui.view" id="oemedical_lab_view">
                    <field name="name">Lab Test</field>
                    <field name="model">oemedical.lab</field>
                    <field name="type">form</field>
                    <field name="arch" type="xml">
                            <form string="Laboratory Test">
                <notebook>
                    <page string="Main Info">
                        <field name="name" required="1"></field>
                        <field name="test" required="1"></field>
                        <field name="date_analysis"></field>
                        <newline/>
                        <field name="patient" required="1"></field>
                        <field name="pathologist"></field>
                        <newline/>
                        <field name="date_requested"></field>
                        <field name="requestor" required="1"></field>

                    <field name="critearea" colspan="4" nolabel="1">
                        <tree editable="top" string="Test Cases">
                            <field name="sequence"/>
                            <field name="name"/>
                            <field name="result"/>
                            <field name="normal_range"/>
                            <field name="units"/>
                        </tree>
                        <form string="Test Cases">
                            <field name="name"/>
                            <field name="result"/>
                            <field name="units"/>
                            <field name="normal_range"/>
                        </form>
                    </field>

                    </page>
                    <page string="Extra Info">
                        <field name="results"></field>
                        <newline/>
                        <field name="diagnosis"></field>
                    </page>
                </notebook>
                            </form>
                    </field>
            </record>



            <record model="ir.ui.view" id="oemedical_lab_tree">
                    <field name="name">Lab test type</field>
                    <field name="model">oemedical.lab</field>
                    <field name="type">tree</field>
                    <field name="arch" type="xml">
                            <tree string='Lab test type'>
                                    <field name="name"></field>
                                    <field name="test"></field>
                                    <field name="patient"></field>
                                    <field name="date_analysis"></field>
                            </tree>
                    </field>
            </record>

            <record model="ir.actions.act_window" id="oemedical_action_tree_lab">
                    <field name="name">Lab Tests Results</field>
                    <field name="type">ir.actions.act_window</field>
                    <field name="res_model">oemedical.lab</field>
                    <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
                    <field name="view_id" ref="oemedical_lab_tree"/>
            </record>

    <menuitem action="oemedical_action_tree_lab" id="oemedical_action_lab_tree" parent="oemedical_laboratory_menu" sequence="2"/>



<act_window domain="[('patient', '=', active_id)]" id="act_patient_lab_history" name="Lab Reports" res_model="oemedical.lab" src_model="oemedical.patient"/>

    <record id="view_oemedical_lab_test_results_filter" model="ir.ui.view">
        <field name="name">Lab Tests Results</field>
        <field name="model">oemedical.lab</field>
        <field name="type">search</field>
        <field name="arch" type="xml">
            <search string="Search Lab Tests Results">

                <separator orientation="vertical"/>
                    <field name="name" select="1"/>
                    <field name="test" select="1"/>
                    <field name="patient" select="1"/>
                    <field name="date_analysis" select="1"/>
                <newline/>

            </search>
        </field>
    </record>



</data>