mardi 4 août 2015

XNA / Monogame Texture2D to to string

I want to store a small png image in a XML file and Load it back to Texture2D.

This is what I'm doing

Code for saving

I'm writing the data of the Texture2D with the BinaryWriter to a MemoryStream,

then converting the MemoryStream to an Array. I have to Convert the array to a Base64String because you can't save all characters

in a XML file.

The string is saved in my XML file.

    public static string SaveTextureData(this Texture2D texture)
    {
        int width = texture.Width;
        int height = texture.Height;
        Color[] data = new Color[width * height];
        texture.GetData<Color>(data, 0, data.Length);

        MemoryStream streamOut = new MemoryStream();

        BinaryWriter writer = new BinaryWriter(streamOut);

           writer.Write(width);
            writer.Write(height);
            writer.Write(data.Length);

            for (int i = 0; i < data.Length; i++)
            {
                writer.Write(data[i].R);
                writer.Write(data[i].G);
                writer.Write(data[i].B);
                writer.Write(data[i].A);
            } 

        return Convert.ToBase64String(streamOut.ToArray());
    }

Code for Loading

Same here.. I'm converting the Base64Str to an array and trying to read it.

But I cant read it back.

    public static Texture2D LoadTextureData(this string gfxdata, GraphicsDevice gfxdev)
    {
        byte[] arr = Convert.FromBase64String(gfxdata);

        MemoryStream input = new MemoryStream();

        BinaryWriter bw = new BinaryWriter(input);
        bw.Write(arr);

        using (BinaryReader reader = new BinaryReader(input))
        {
            var width = reader.ReadInt32();
            var height = reader.ReadInt32();
            var length = reader.ReadInt32();
            var data = new Color[length];

            for (int i = 0; i < data.Length; i++)
            {
                var r = reader.ReadByte();
                var g = reader.ReadByte();
                var b = reader.ReadByte();
                var a = reader.ReadByte();
                data[i] = new Color(r, g, b, a);
            }

            var texture = new Texture2D(gfxdev, width, height);
            texture.SetData<Color>(data, 0, data.Length);
            return texture;
        }
    }

Could need some help here.

Getting an exception in the reading method that the value couldnt read. in line var width = reader.ReadInt32();

R devtools fails as "Package libxml-2.0 was not found in the pkg-config search path"

I am trying to install devtools in R version 3.2.1, however when I do the following error is thrown:

Package libxml-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing libxml-2.0.pc
to the PKG_CONFIG_PATH environment variable

when I run dpkg -L libxml2-dev in a terminal I find:

/usr
/usr/bin
/usr/bin/xml2-config
/usr/share
/usr/share/aclocal
/usr/share/aclocal/libxml2.m4
/usr/share/doc
/usr/share/doc/libxml2-dev
/usr/share/doc/libxml2-dev/copyright
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/xml2-config.1.gz
/usr/share/man/man3
/usr/share/man/man3/libxml.3.gz
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libxml2.a
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/libxml-2.0.pc
/usr/lib/x86_64-linux-gnu/xml2Conf.sh
/usr/include
/usr/include/libxml2
/usr/include/libxml2/libxml
/usr/include/libxml2/libxml/globals.h
/usr/include/libxml2/libxml/schematron.h
/usr/include/libxml2/libxml/xlink.h
/usr/include/libxml2/libxml/HTMLparser.h
/usr/include/libxml2/libxml/pattern.h
/usr/include/libxml2/libxml/xmlexports.h
/usr/include/libxml2/libxml/xmlschemas.h
/usr/include/libxml2/libxml/list.h
/usr/include/libxml2/libxml/entities.h
/usr/include/libxml2/libxml/xmlstring.h
/usr/include/libxml2/libxml/encoding.h
/usr/include/libxml2/libxml/hash.h
/usr/include/libxml2/libxml/xmlmemory.h
/usr/include/libxml2/libxml/relaxng.h
/usr/include/libxml2/libxml/xmlsave.h
/usr/include/libxml2/libxml/SAX2.h
/usr/include/libxml2/libxml/xmlIO.h
/usr/include/libxml2/libxml/xmlschemastypes.h
/usr/include/libxml2/libxml/xpathInternals.h
/usr/include/libxml2/libxml/schemasInternals.h
/usr/include/libxml2/libxml/xmlmodule.h
/usr/include/libxml2/libxml/valid.h
/usr/include/libxml2/libxml/c14n.h
/usr/include/libxml2/libxml/xmlwriter.h
/usr/include/libxml2/libxml/tree.h
/usr/include/libxml2/libxml/xmlunicode.h
/usr/include/libxml2/libxml/nanohttp.h
/usr/include/libxml2/libxml/catalog.h
/usr/include/libxml2/libxml/xmlerror.h
/usr/include/libxml2/libxml/nanoftp.h
/usr/include/libxml2/libxml/xmlautomata.h
/usr/include/libxml2/libxml/xinclude.h
/usr/include/libxml2/libxml/HTMLtree.h
/usr/include/libxml2/libxml/chvalid.h
/usr/include/libxml2/libxml/parserInternals.h
/usr/include/libxml2/libxml/xpointer.h
/usr/include/libxml2/libxml/xmlversion.h
/usr/include/libxml2/libxml/dict.h
/usr/include/libxml2/libxml/xmlregexp.h
/usr/include/libxml2/libxml/DOCBparser.h
/usr/include/libxml2/libxml/parser.h
/usr/include/libxml2/libxml/xmlreader.h
/usr/include/libxml2/libxml/SAX.h
/usr/include/libxml2/libxml/threads.h
/usr/include/libxml2/libxml/debugXML.h
/usr/include/libxml2/libxml/xpath.h
/usr/include/libxml2/libxml/uri.h
/usr/share/doc/libxml2-dev/README
/usr/share/doc/libxml2-dev/NEWS.gz
/usr/share/doc/libxml2-dev/AUTHORS
/usr/share/doc/libxml2-dev/TODO.gz
/usr/share/doc/libxml2-dev/changelog.Debian.gz
/usr/lib/x86_64-linux-gnu/libxml2.so

to try and add this to the PKG_CONFIG_PATH I tried: env PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig however this does not seem to work.

How to manipulate a tabbed view in Titanium and add SQLite content?

The Overview

I am fairly new to Titanium and I decided to finally start working with SQLite and some new UI features. I opted for the TabGroup as I felt that would be the best option. However I'm having a few issues. I am trying to simply get some quotes which have been inserted to a table (tested and working, I alerted them out and it worked) and I wish to display them out in the wiseWords tab, so the user can view them.

The Code

index.xml

<Alloy id="index">
    <TabGroup>
        <Require src="home"></Require>
        <Require src="wiseWords"></Require>
        <Require src="settings"></Require>
    </TabGroup>
</Alloy>

index.js

$.index.open(); 

/** Create and populate the wise words table. **/
Alloy.Globals.createRequiredTables();

var selectWiseWordsSQL = "SELECT * FROM wise_words";
var selectWiseWords = Titanium.App.db.execute(selectWiseWordsSQL);

while (selectWiseWords.isValidRow()) {
    /** Create labels for each quote. **/
    var addQuote = Titanium.UI.createLabel({
        text : selectWiseWords.fieldByName("saying") + " - " + selectWiseWords.fieldByName("quoted_by"),
    });

    /** Add quote to window (available in wiseWords.xml). **/
    $.wiseWordsWindow.add(addQuote);

    selectWiseWords.next();
}
selectWiseWords.close();

wiseWords.xml

<Alloy>
    <Tab id="wiseWordsTab" title="Wise Words">
        <Window id="wiseWordsWindow" class="container" title="Wise Words">  
        </Window>
    </Tab>
</Alloy>

The Error(s)

Runetime Error

Location: alloy/controllers/index.js

Uncaught TypeError: Cannot call method 'add' of undefined.

Source: $.wiseWordsWindow.add(addQuote);

To Clarify...

I understand what the error means, but don't understand why it is being thrown.

  1. Why can't I access the view for wiseWords.xml in index.js even though wiseWords is referenced in index.xml through the <Require> tag?

registerClassCommandBinding / Ribbon Class - Binding not firing

I'm trying to implement contextual help, when a button in the Ribbon Class has been selected. Try as I might, I can't seem to get the button firing on the Application Help command via this binding:

            CommandManager.RegisterClassCommandBinding(typeof(UIElement), new CommandBinding(ApplicationCommands.Help, new ExecutedRoutedEventHandler(ShowHelpExecuted),
                   new CanExecuteRoutedEventHandler(ShowHelpCanExecute)));

I've even tried this:

                CommandManager.RegisterClassCommandBinding(typeof(**RibbonToggleButton**), new CommandBinding(ApplicationCommands.Help, new ExecutedRoutedEventHandler(ShowHelpExecuted),
                   new CanExecuteRoutedEventHandler(ShowHelpCanExecute)));

For a direct binding to the button class, but I still don't get called when the Help (F1) button is called.

What does happen is the method is invoked, but the sender of the method is the main from that the control resides on, rather than the actual button that has focus. I want to provide help specific to the control that has focus (in this case the button), rather than just the form that the button resides on.

Here's a portion of the XML for the ribbon until the first toggle button

<Grid Name="GridRibbonBar"
          Grid.Row="0"
          Grid.Column="0"
          IsHitTestVisible="True">


        <Ribbon x:Name="RibbonMain"
                Background="AliceBlue"
                ContextMenu="{x:Null}"
                PreviewMouseLeftButtonDown="RibbonMain_OnPreviewMouseLeftButtonDown"
                ShowQuickAccessToolBarOnTop="False">


            <Ribbon.TitleTemplate>
                <DataTemplate>
                    <TextBlock TextAlignment="Center"
                               HorizontalAlignment="Center"
                               VerticalAlignment="Center"
                               FontWeight="SemiBold"
                               Width="{Binding ElementName=Window, Path=ActualWidth}"
                               Text="{x:Static p:Resources.Title}">
                        <TextBlock.Effect>
                            <DropShadowEffect ShadowDepth="0"
                                              Color="MintCream "
                                              BlurRadius="10" />
                        </TextBlock.Effect>
                    </TextBlock>
                </DataTemplate>
            </Ribbon.TitleTemplate>

            <Ribbon.ApplicationMenu>
                <RibbonApplicationMenu Visibility="Collapsed" />
            </Ribbon.ApplicationMenu>

            <!--Options Tab-->
            <RibbonTab Header="{x:Static p:Resources.treeHdrOptions}"
                       ContextMenu="{x:Null}">
                <RibbonGroup Header="{x:Static p:Resources.ribbonGroupGuestAccount}"
                             Visibility="{Binding Path=LoginViewModel.User.IsOwnerOrPowerOfAttorney,Converter={StaticResource VisibilityConverter},Source={StaticResource ViewModelLocatorService}}"
                             ContextMenu="{x:Null}">
                    <RibbonGroup.ItemsPanel>
                        <ItemsPanelTemplate>
                            <WrapPanel Orientation="Horizontal"
                                       Width="50" />
                        </ItemsPanelTemplate>
                    </RibbonGroup.ItemsPanel>
                    <RibbonToggleButton Name="guestacount"
                                        Visibility="{Binding Path=LoginViewModel.User.IsOwnerOrPowerOfAttorney,Converter={StaticResource VisibilityConverter},Source={StaticResource ViewModelLocatorService}}"
                                        Label="{x:Static p:Resources.treeGuest}"
                                        SmallImageSource="../images/RibbonIcons/PNGFormat/GeneralGuest.png"
                                        LargeImageSource="../images/RibbonIcons/PNGFormat/GeneralGuest.png"
                                        Checked="RibbonToggleButton_OnChecked"
                                        ContextMenu="{x:Null}" />
                </RibbonGroup>
            </RibbonTab>

Multiple Ribbon XML in one Add-In

I want to have two Ribbon XML in one Outlook Add-In. Ribbon2 is a button in a context menu and Ribbon1 is a tab in Outlook Mail Read. I did this - VSTO - Is it possible to have both designer and XML ribbons?, but then getLabel, getVisible, etc, doesn't work! Can you please help me? Thanks!!

ImageView in SurfaceView without XML

My question is if is possible add an ImageView in a SurfaceView without XML. If yes, how? I have a main class that has the function of GamePanel, and for apply a Method i need to call it with an ImageView, but i don't know if it is possible. Thanks you in advance.

XMLStreamReader how to work with nested elements of same type

I'm working with the XMLStreamReader and parsing the following XML:

<root>
    <element>
        <attribute>level0</attribute>
        <element>
            <attribute>level1</attribute>
            <element>
                <attribute>level2</attribute>
            </element>
        </element>
    </element>
</root>

I'm building out my XMLStreamReader:

XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(
                new ByteArrayInputStream(document.getBytes()));

Unfortunately, when I get to the first closing element tag with reader.next();, I get the following exception:

javax.xml.stream.XMLStreamException: ParseError at [row,col]:[7,14]
Message: XML document structures must start and end within the same entity. 

Is there a way to override the default behavior of the XMLStreamReader to get around with this?

Android Application is able to run smoothly but show up blank page

In my database I have 2 tables, table category, and table menu. In the category table, each restaurant has different category(i.e Restaurant1: {category: food, beverage}, Restaurant2: {category: snacks,dessert}. Now I want to retrieve the menu for each category of the selected restaurant as an expandable list. the category name as the group list and the menu in that category as the child list. So far I have managed to retrieve the array of data and tried to use my own custom adapter to create the expandablelist, but the app is able to run but shows a blank page.

MainActivity.java

package com.example.ed.expandablelistview;

import android.app.Activity;
import android.content.Context;
import android.os.AsyncTask;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
import android.widget.TextView;
import android.widget.Toast;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;


public class MainActivity extends Activity {

HashMap<String, List<String>> countriesHashMap;
List<String> countriesHashMapKeys;
ExpandableListView expandableListView;
MyCustomAdapter adapter;

private static final String TAG_SUCCESS = "success";
private static final String TAG_CAT_LIST = "cat_list";
private static final String TAG_MENU_LIST = "menu_list";
private static final String TAG_CAT = "category";
private static final String TAG_ITEM = "item";

private static String url_get_menu_list = "http://ift.tt/1N7UEJV";
private static String url_get_cat_list = "http://ift.tt/1VZuYVP";

ArrayList<HashMap<String, String>> catList;

JSONArray menu_list = null;

List<String> catFoodList = new ArrayList<String>();

HashMap<String, List<String>> menuHashMap = new HashMap<String, List<String>>();

JSONParser jParser = new JSONParser();
JSONArray cat_list = null;
String rest_name, rest_pid;

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

    new ShowMenu().execute();

    expandableListView = (ExpandableListView) findViewById(R.id.expandableList);
    countriesHashMap = menuHashMap;
    countriesHashMapKeys = new ArrayList<String>(countriesHashMap.keySet());

    adapter = new MyCustomAdapter(this, countriesHashMap, countriesHashMapKeys);
    expandableListView.setAdapter(adapter);

}

public class ShowMenu extends AsyncTask<String, HashMap<String, List<String>>, String> {

    protected String doInBackground(String... args) {

        rest_name = "Restaurant";
        rest_pid = "2";

        catList = new ArrayList<HashMap<String, String>>();

        //building params
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("rest", rest_name));
        params.add(new BasicNameValuePair("pid", rest_pid));

        //getting JSON string from url
        JSONObject json = jParser.makeHttpRequest(url_get_cat_list, "GET", params);

        //check log cat for response
        Log.d("Menu : ", json.toString());

        //Get Array of category list
        try {
            //check for success tag
            int success = json.getInt(TAG_SUCCESS);

            if (success == 1) {
                //get array of menu
                cat_list = json.getJSONArray(TAG_CAT_LIST);

                //looping through all cat_list
                for (int i = 0; i < cat_list.length(); i++) {
                    JSONObject c = cat_list.getJSONObject(i);

                    //storing each json in variable
                    String category = c.getString(TAG_CAT);

                    //creating new hashmap
                    HashMap<String, String> map = new HashMap<String, String>();

                    //adding each child node to hashmap key => value
                    map.put(TAG_CAT, category);

                    //add hashlist to arraylist
                    catList.add(map);

                    //Build params to get menu of category
                    List<NameValuePair> mparams = new ArrayList<NameValuePair>();
                    mparams.add(new BasicNameValuePair("get_cat", category));
                    mparams.add(new BasicNameValuePair("get_pid", rest_pid));

                    //get menu of category
                    JSONObject menujson = jParser.makeHttpRequest(url_get_menu_list, "GET", mparams);

                    //check log cat for response
                    Log.d("Menu : ", menujson.toString());

                    try {
                        //check for success tag
                        int msuccess = menujson.getInt(TAG_SUCCESS);

                        if (msuccess == 1) {
                            //get array of menu
                            menu_list = json.getJSONArray(TAG_MENU_LIST);

                            for (int m = 0; m < menu_list.length(); m++) {
                                JSONObject l = menu_list.getJSONObject(m);
                                String item = l.getString(TAG_ITEM);
                                catFoodList.add(item);
                            }
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                    menuHashMap.put(category, catFoodList);

                }
            } else {
                //no category found
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;

    }
}

}

MyCustomAdapter.java

package com.example.ed.expandablelistview;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;

import java.util.HashMap;
import java.util.List;


public class MyCustomAdapter extends BaseExpandableListAdapter {

private Context context;
private HashMap<String, List<String>> countriesHashMap;
private List<String> countryList;

public MyCustomAdapter(Context context,
                       HashMap<String, List<String>> hashMap,
                       List<String> list) {
    countriesHashMap = hashMap;
    this.context = context;
    this.countriesHashMap = hashMap;
    this.countryList = list;
}

@Override
public int getGroupCount() {
    return countriesHashMap.size();
}

@Override
public int getChildrenCount(int groupPosition) {
    return countriesHashMap.get(countryList.get(groupPosition)).size();
}

@Override
public Object getGroup(int groupPosition) {
    return countryList.get(groupPosition);
}

@Override
public Object getChild(int groupPosition, int childPosition) {
    return countriesHashMap.get(countryList.get(groupPosition)).get(childPosition);
}

@Override
public long getGroupId(int groupPosition) {
    return groupPosition;
}

@Override
public long getChildId(int groupPosition, int childPosition) {
    return childPosition;
}

@Override
public boolean hasStableIds() {
    return false;
}

@Override
public View getGroupView(int groupPosition, boolean isExpanded,
                         View convertView, ViewGroup parent) {
    String groupTitle = (String) getGroup(groupPosition);
    if (convertView == null) {
        LayoutInflater inflater =
                (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.parent_layout, parent, false);
    }
    TextView parentTextView = (TextView) convertView.findViewById(R.id.textViewParent);
    parentTextView.setText(groupTitle);
    return convertView;
}

@Override
public View getChildView(int groupPosition,
                         int childPosition,
                         boolean isLastChild, View convertView, ViewGroup parent) {
    String childTitle = (String) getChild(groupPosition, childPosition);
    if(convertView == null) {
        LayoutInflater inflater =
                (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.child_layout, parent, false);
    }
    TextView childTextView = (TextView) convertView.findViewById(R.id.textViewChild);
    childTextView.setText(childTitle);
    TextView childTextView2 = (TextView) convertView.findViewById(R.id.textViewChild2);
    childTextView2.setText("test");
    return convertView;
}

@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
    return true;
}
}

activity_main.xml

<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

<ExpandableListView
    android:id="@+id/expandableList"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:divider="@color/green"
    android:dividerHeight="10dp"
    android:indicatorLeft="?android:attr/expandableListPreferredItemIndicatorLeft"
    ></ExpandableListView>

</RelativeLayout>

parent_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="match_parent" android:layout_height="match_parent">

<TextView
    android:id="@+id/textViewParent"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingBottom="10dp"
    android:paddingLeft="?android:attr/expandableListPreferredItemPaddingLeft"
    android:paddingTop="10dp"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="@color/red"
    android:textStyle="bold"/>

</LinearLayout>

child_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="match_parent" android:layout_height="match_parent">

<TextView
android:id="@+id/textViewChild"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/orange_dark"
android:gravity="center_horizontal"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@android:color/white"
/>

</LinearLayout>

I have managed to retrieve the data of the category and the menu from my database as an array, which I put in the hashmap and use the adapter to the expandablelist, but the app shows blank page. All answers and suggestions are greatly welcomed. Thanks in advance.

Two relatives, same height

I have two RelativeLayouts (one next to each other). A White RelativeLayout and red RelativeLayout. As the amount of the text of the white side increases, I want the the red side grow.

what is the best data model to represent mathematical range (in database,xml,json...)?

mathematical range,for example:

greater or equal to 50 and smaller than 100 (>=50 && < 100)

smaller than 10 or greater than 40 (<10 || >40)

I have been thinking about how to represent mathematical range in a file and database, the range may be input by non programmer and I need to keep the input simple,but at another side, it also need to keep the input easy to convert to data and easy to check error input e.g.:"<10 || >100" seems the most simple but it is harder for me to parse the string to get the data,also need to consider input format error

I have been considering some input methods,using >=50 && < 100 as example,which is in key value form:

1.using 1 string to represent whole range:

<rangeInString>=50 && < 100</rangeInString>

2.separate 2 strings,one represent lower bound and another one represent upper bound,then parse each string in program:

<lowerBound> >=50 </lowerBound>
<upperBound> <100 </upperBound>

3.separate lower and upper bound,also separate the sign from number:

<lowerBound>
    <sign> >= </sign>
    <data>50</data>
</lowerBound>
<upperBound>
    <sign> < </sign>
    <data>100</data>
</upperBound>

4.separate lower bound and upper bound,also separate sign, and also separate the case that if includes the equal condition:

<lowerBound>
    <sign> > </sign>
    <isIncludeEqual>true</isIncludeEqual>
    <data>50</data>
</lowerBound>
<upperBound>
    <sign> < </sign>
    <isIncludeEqual>false</isIncludeEqual>
    <data>100</data>
</upperBound>

5.auto detect using "&&" or "||",e.g.:>= A with < B,if A < B,must be "&&" e.g.(>= 50 && <100),otherwise it is "||" e.g.(>= 100 || <50):

<A>
    <sign> > </sign>
    <isIncludeEqual>true</isIncludeEqual>
    <data>50</data>
</A>
<B>
    <sign> < </sign>
    <isIncludeEqual>false</isIncludeEqual>
    <data>100</data>
</B>

6.use a field "isAnd" to separate >=50 && < 100 (true) and <=50 || > 100 (false)instead of using field sign "<" and ">" :

<lowerBound>
    <isIncludeEqual>true</isIncludeEqual>
    <data>50</data>
</lowerBound>
<upperBound>
    <isIncludeEqual>false</isIncludeEqual>
    <data>100</data>
</upperBound>
<isAnd>true</isAnd>

7.other data model...

I need to consider somethings:

1.easy for non programmer to input

2.easy to convert or parse to data into program

3.easy to check error ,for example,parse string increase the complexity of converting data and checking incorrect format,also there may have other incorrect format,e.g.:<=50 && >100 should not be valid, I may allow auto detect using "&&" or "||" by the sign of input,but it may increase the complexity of the code

can anyone have idea?

Which one better for XML data Mongodb or orientdb

I cannot use an XML base database. Have to choose from mongo DB or orient DB. Which one will be more suitable for XML based data. where I can directly save or fetch XMLs, run xpath, jquery.

XML5617: Illegal XML character in IE9

My applications is working in IE11, Chrome but not in IE9. It gives XML5617: Illegal XML character error, but there is no illegal character, other wise it will not work in IE11 and Chrome. I am using Ajax to load the data. I am lost. Thanks for help.

Also it works in IE9 for english language customers but not for non-english.

Python “Walk” directory to deal with xml

I'm a new comer about python, and I code this program to deal with xml in os.walk(). This program can print "channel code" from different xml files, and they all named "mmiap.xml".

It is the code:

#coding=utf-8
import os
import  xml.dom.minidom


path = "H:\\Dev\\CODE\\MMwithwalk\\"

for root, dirs,files in os.walk(path):

    dom = xml.dom.minidom.parse('mmiap.xml')

    root = dom.documentElement

    bb = root.getElementsByTagName('channel')   #Get channel code from mmiap.xml

    b= bb[0]

    print (b.firstChild.data)

After run this program, it shows "FileNotFoundError: [Errno 2] No such file or directory: 'mmiap.xml'"

What's wrong? It seems that traversal is not walk depth. But I can't find the problem.

PS: If I drag a mmiap.xml to root directory, channel code will be printed normally.

Trouble matching a regex part of an XML with java

Hello I got a problem using the regex with Java.

I'm trying to parse this :

*whatever string*
<AttributeDesignator AttributeId="MyIDToParse"
DataType="http://ift.tt/QHQMAU"
Category="theCategoryIWantToParse"
MustBePresent="false"
/>
*whatever string that may contain the same regular expression*

using this code (Pattern + Matcher)

Pattern regex = Pattern.compile("AttributeDesignator +AttributeId=\"(.+)\" +.*Category=\"(.+)", Pattern.DOTALL);
Matcher matcher = regex.matcher(xml);
while (matcher.find()) {
    String ID = matcher.group(1);
    String Category = matcher.group(2);

The output is the following :

group 1 :

MyIDToParse"
    DataType="http://ift.tt/QHQMAU"
    Category="theCategoryIWantToParse"
    MustBePresent="false"
    />
    *whatever string that may contain the same regular expression*

group2 :

theCategoryIWantToParse"
    MustBePresent="false"
    />
    *whatever string that may contain the same regular expression*

I feel like it's a simple thing but I can't find whatever I'm doing wrong.. When I used the regex in a website to test them it works correctly and highlight the right expression from my xml entry.

Line breaks in PHP xmlwriter document

I've got an XML feed I've created using XMLWriter. It works flawlessly in dev on a PHP 5.6 vagrant box. On the live server, running PHP 5.4 the feed fails to render with a message:

This page contains the following errors:

error on line 3 at column 6: XML declaration allowed only at the start of the document

If you view source it looks like this:

source

Somehow there are a couple lines being added into the XML document. The only difference between the servers is the PHP version (as far as I know).

Here's the first few lines of the XMLWriter code:

$xml = new XMLWriter();
$xml->openURI('php://output');
$xml->startDocument("1.0");
$xml->setIndent(true);
$xml->startElement("propertyList");
$xml->writeAttribute('date', date('Y-m-d-H:i:s'));

Any ideas how to get around this?

Extraction of data from Soap Response in Php

I did a SOAP/WSDL request with a PHP script. I could access an answer which look like this :

stdClass Object
(
     [inventory] => Array[inventory] => Array
     (
        [0] => stdClass Object
               (
                [location_inventory] => stdClass Object
                    (
                        [location] => stdClass Object
                            (
                                [organization] => abcdef
                                [contact] => stdClass Object
                                    (
                                        [contact_details] => stdClass Object
                                            (
                                                [id] => Thomas
                                            )
                                    )
                            )
                        [product] => tomatoes
                    )
            )
    )
)

The point is that I can't extract the variables "organization", "id", or "product".

What is the difference of syntax when accessing a stdClass Object or an Array ?

Google Sheet - Imported XML Content Parse Error

Even though Google has now fixed the Importxml error with the new Google sheets, I am still having problems with the below query:

=IMPORTXML("http://ift.tt/1VZhqK1","/progressives//game table[1]@jackpot")

Any ideas why this could be?

cheers!

Xpath Contains Query on child node to return Parent node

String query = null;
XPathExpression expr;
Object Result = null;

expr = xpath.compile("//table/column[contains(translate(text(),'ABCDEFGHIJKLMNAOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),'"+query+"')]//text()");

result = expr.evaluate(doc, XpathConstants.NODESET);

NodeList nodes = (NodeList) result;

for (int i = 0; i<nodes.getLength(); i++){
     System.out.println(nodes.item(i).getParentNode().getNodeName() + "" + nodes.item(i).getNodeValue());
}

Hi, so I want to start off by saying I am new to xpath and fairly new to java. I am trying to create a query interface for this large xml file and this is what I have come up with so far. The xml file is full of logs and it is setup somewhat like this.... ..... The code works well at pulling back the column that match the search term however I would like it to pull back the whole table and then print it out. this will give me more valuable info including the date stamp the person who entered it ect.... I have tried various things from trying to get the parentnode from nodes(i) then putting the .getchildnodes into another nodelist but that didn't work at all. I also tried adding /.. at the end of the xpath before the text() to see if it would give me back the parent but that ended up just giving me the root tag somehow. I think I am kinda close, maybe not I don't know but if anyone can help that would be much appreciated, I have been stuck on this for a while now.

best way to compare xml data's and present that to user as HTML

Consider the following two different xml based result/response, all follow same xsd in general

    xml1: 
    <student name="1" rollNo="1">
        <result>
            <subject name="lang" marks=90/>
            <subject name="science" marks=80/>
            <subject name="maths" marks=95/>
        </result>
    </student>

    xml2: 
    <student name="2" rollNo="2">
        <result>
            <subject name="lang" marks=100/>
            <subject name="science" marks=90/>
            <subject name="maths" marks=90/>
        </result>
    </student>

    Expected Comparison HTML:

    Students Result:
    ------------------------------------
            |        Subjects           |
    Roll No |---------------------------
            | lang  | science   | maths |   
    -------------------------------------
    1       | 90   |    80      | 95    |   
    2       | 100  |    90      | 90    |
    -------------------------------------

Also consider the future cases like, if the xml evolves with more added details

    <student name="1" rollNo="1">
        <result>
            <subject name="lang">
                <internal =50>
                <external =40>
            </subject>
            ....
        </result>
    </student>

then the table should also presented like

    ----------------------------------------------
            |        Subjects                    |
    Roll No |-------------------------------------
            | lang      | science    | maths     |  
            --------------------------------------
            | int | ext |  int | ext | int | ext |
    ----------------------------------------------
     1      | 50 |  40 |   50  | 30  |  50 |  45 |      
     2      | 50 |  30 |   50  | 45  |  50 |  30 |
    ----------------------------------------------

The same logic, should also be able to compare some other group of xml's, they follow their own kind of xsd's

Consider other kind for ex:

<employee name="1" rollNo="1">  
    <appearance height="" weight=90 gender=""/>
    <department name="HR" role="" experience=""/>
</employee>

<employee name="1" rollNo="1">  
    <appearance height="" weight=90 gender=""/>
    <department name="HR" role="" experience=""/>
</employee>

Expected Comparison HTML:

Employee Comparison:

--------------------------------------------------------
        |        Appearance         |   Department      |
Roll No |-----------------------------------------------|
        | height | weight |  gender |   name | role     |
---------------------------------------------------------
1       |                                               |       
---------------------------------------------------------
2       |                                               |
---------------------------------------------------------

Is there any best/recommended/generic approach to achieve this? Tools? thrid-parties? API's? In terms of performance? maintenance?

Right now, to achieve this, what I have done is step1: append all xml under a single parent [ex: repeating student nodes under students] step2: Write customized xslt for each type of xsd family and digest against the concated xml results and make HTML out of it.

Tools: java - xsd's, xml parsers, xslt, HTML

As per my project req, I expect atleast 30 kind of xsd families, and the comparison framework should support all of them with generic impl.

Any recommendation would be really saving my days :)

Element type "settings" must be followed by either attribute specifications, ">" or "/>"

http://ift.tt/1dFf4uT"   xmlns="http://ift.tt/1dFf4uQ" xmlns:xsi="http://ift.tt/ra1lAU ">      

Javascript Create XML DOM - The Node Object

I have a simple question: How can I create a new Node from scratch?

Here is my situation:

I need to build an XML Structure from an object list.

I have a method ToElement on each control ( Textbox, combobox, ...) and I want this method to return a XML DOM Node object to use the appendChild() and his parent.

I'm not able to find how to create a Node object from scratch I know that I can use an XMLDocument.createElement but this method return an HTMLElement and you can't use appendChild with this kind of element.

nodeObject.appendChild(HTMLelement) //** Not Working**

Is there a way to convert an HTMLElement to a Node ? The only way that I found to create an element it's from a XMLDocument:

XMLDocument.createElement // (Return a new HTMLElement)

Validate ID value by Regular expression or xml.etree.ElementTree

Problem Statement:

I have to validate ID value of all elements in the HTML content. ID value rule is:-

ID value must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

Code by Regular expression

>>> content
'<div id="11"> <p id="34"></p><div id="div2"> </div></div>'
>>> all_ids = re.findall("id=\"([^\"]*)\"", content)
>>> id_validation = re.compile("[A-Za-z][\-A-Za-z0-9_:\.]*$")
>>> invalid_ids = [i for i in all_ids if not bool(id_validation.match(i))]
>>> invalid_ids
['11', '34']

Code by xml.etree.ElementTree parser:

>>> import xml.etree.ElementTree as PARSER
>>> root = PARSER.fromstring(content)
>>> all_ids = [i.attrib["id"] for i in root.getiterator() if "id" in i.attrib]
>>> all_ids
['11', '34', 'div2']
>>> id_validation = re.compile("[A-Za-z][\-A-Za-z0-9_:\.]*$")
>>> [i for i in all_ids if not bool(id_validation.match(i))]
['11', '34']
>>>

It also one line by lxml, but exiting code NOT use lxml lib due to some reason.

>>> from lxml import etree
>>> root = etree.fromstring(content)
>>> root.xpath("//*/@id")
['11', '34', 'div2']

The input content contains 100000 of tags, so which is above process best for performance?

Retrofit with Simpleframework XML

I'm using retrofit to connect to my API and trying to parse messages with Simpleframework XML, but I keep getting the error below:

retrofit.RetrofitError: org.simpleframework.xml.core.ElementException: Element 'head' does not have a match in class Classes at line 5

Here are my classes and XML

@Root(name = "tables")
public class Classes
{
   @ElementList(name = "tables", inline = true)
   List<MyClass> tables;
}

:

Root(name="table")

public class MyClass implements Serializable
{
    @Element(name = "id")
    private String id;

    @Element(name = "name")
    private String name;

    @Element(name = "value")
    private String value;

    @Element(name = "key")
    private String key;
}

XML:

<?xml version="1.0" encoding="UTF-8"?>
<tables>
   <table>
      <id>1</id>
      <name>Admin</name>
      <value>111</value>
      <key>999</key>
   </table>
   <table>
      <id>5</id>
      <name>Bari Limani</name>
      <value>121</value>
      <key>999</key>
</tables>

Why does struts.xml have a configuration error?

I'm receiving a configuration error in the file struts.xml

Error

The content of element type "package" must match "
(result-types?,interceptors?,default-interceptor-ref?,
default-action-  ref?,default-class-ref?,global-results?,
global-exception-mappings?,action*)".

What does the error description mean?

struts.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://ift.tt/1iwXH3l">

<struts>

    <constant name="struts.devMode" value="true" />

    <package name="basicstruts2" extends="struts-default">

        <global-results>
            <result name="securityerror">/securityerror.jsp</result>
            <result name="error">/error.jsp</result>
        </global-results>

        <global-exception-mappings>
            <exception-mapping
                exception="org.apache.struts.register.exceptions.SecurityBreachException"
                result="securityerror" />
            <exception-mapping exception="java.lang.Exception"
                result="error" />
        </global-exception-mappings>

        <interceptors>
            <interceptor-stack name="appDefaultStack">
                <interceptor-ref name="defaultStack">
                    <param name="exception.logEnabled">true</param>
                    <param name="exception.logLevel">ERROR</param>
                </interceptor-ref>
            </interceptor-stack>
        </interceptors>

        <default-interceptor-ref name="appDefaultStack" />

        <action name="actionspecificexception" class="org.apache.struts.register.action.Register"
            method="throwSecurityException">
            <exception-mapping
                exception="org.apache.struts.register.exceptions.SecurityBreachException"
                result="login" />
            <result>/register.jsp</result>
            <result name="login">/login.jsp</result>
        </action>

        <action name="index">
            <result>/index.jsp</result>
        </action>

        <!-- If the URL is hello.action the call the execute method of class HelloWorldAction. 
            If the result returned by the execute method is success render the HelloWorld.jsp -->
        <action name="hello"
            class="org.apache.struts.helloworld.action.HelloWorldAction" method="execute">
            <result name="success">/HelloWorld.jsp</result>
        </action>

        <action name="register" class="org.apache.struts.register.action.Register"
            method="execute">
            <result name="success">/thankyou.jsp</result>
            <result name="input">/register.jsp</result>
        </action>

        <action name="registerInput" class="org.apache.struts.register.action.Register"
            method="input">
            <result name="input">/register.jsp</result>
        </action>

    </package>

</struts>

How to write a "filter" stream wrapper for XML?

I have some large XML feed files with illegal characters in them (0x1 etc). The files are third-party, I cannot change the process for writing them.

I would like to process these files using an XmlReader, but it blows up on these illegal characters.

I could read the files, filter out the bad characters, save them, then process them... but this is a lot of I/O, and it seems like it should be unnecessary.

What I would like to do is something like this:

using(var origStream = File.OpenRead(fileName))
using(var cleanStream = new CleansedXmlStream(origStream))
using(var streamReader = new StreamReader(cleanStream))
using(var xmlReader = XmlReader.Create(streamReader))
{
    //do stuff with reader
}

I tried inheriting from Stream, but when I got to implementing the Read(byte[] buffer, int offset, int count) I lost some confidence. After all, I was planning on removing characters, so it seemed the count would be off, and I'd have to translate each byte to a char which seemed expensive (especially on large files) and I was unclear how this would work with a Unicode encoding, but the answers to my questions were not intuitively obvious.

When googling for "c# stream wrapper" or "c# filter stream" I am not getting satisfactory results. It's possible I'm using the wrong words or describing the wrong concept, so I'm hoping the SO community can square me away.

Using the example above, what would CleansedXmlStream look like?

Here's what my first attempt looked like:

public class CleansedXmlStream : Stream
{
    private readonly Stream _baseStream;

    public CleansedXmlStream(Stream stream)
    {
        this._baseStream = stream;
    }

    public new void Dispose()
    {
        if (this._baseStream != null)
        {
            this._baseStream.Dispose();
        }
        base.Dispose();
    }

    public override bool CanRead
    {
        get { return this._baseStream.CanRead; }
    }

    public override bool CanSeek
    {
        get { return this._baseStream.CanSeek; }
    }

    public override bool CanWrite
    {
        get { return this._baseStream.CanWrite; }
    }

    public override long Length
    {
        get { return this._baseStream.Length; }
    }

    public override long Position
    {
        get { return this._baseStream.Position; }
        set { this._baseStream.Position = value; }
    }

    public override void Flush()
    {
        this._baseStream.Flush();
    }

    public override int Read(byte[] buffer, int offset, int count)
    {
        //what does this look like?

        throw new NotImplementedException();
    }

    public override long Seek(long offset, SeekOrigin origin)
    {
        return this._baseStream.Seek(offset, origin);
    }

    public override void SetLength(long value)
    {
        this._baseStream.SetLength(value);
    }

    public override void Write(byte[] buffer, int offset, int count)
    {
        throw new NotSupportedException();
    }
}

StAX cursor does not retrieve attribute's data

for the belwo posted xml file, i am using StAX to process it. i wote the below code, but i do not know why there are no info about the attribute are printed despite there are attributes in the xml file. i expected the console to show info about "id" and "lat" and "lon" attributes

coed:

        for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) {

        switch (event) {
        case XMLStreamConstants.START_ELEMENT:
            Log.d(TAG, "main", "@START_ELEMENT");
            Log.d(TAG, "main", "getLocalName(): "+parser.getLocalName());
            Log.d(TAG, "main", "getAttributeCount(): "+parser.getAttributeCount());
            break;

        case XMLStreamConstants.CHARACTERS:
            //Log.d(TAG, "main", "@CHARACTERS");
            //Log.d(TAG, "main", "getTextLength(): "+parser.getTextLength());
            break;

        case XMLStreamConstants.ATTRIBUTE:
            Log.d(TAG, "main", "@ATTRIBUTE");
            Log.d(TAG, "main", "getText():"+parser.getText());
            Log.d(TAG, "main", "getAttributeCount(): "+parser.getAttributeCount());
            Log.d(TAG, "main", "getAttributeCount(): "+parser.getAttributeLocalName(0));
            break;

        case XMLStreamConstants.END_ELEMENT:
            Log.d(TAG, "main", "@END_ELEMENT");
            Log.d(TAG, "main", "getText():"+parser.getLocalName());
            break;
        }

    }

xml:

<?xml version='1.0' encoding='utf-8' ?>
<osm>
<node id="25779111" lat="53.0334062" lon="8.8461545"/>
<node id="25779112" lat="53.0338904" lon="8.846314"/>
<node id="25779119" lat="53.0337395" lon="8.8489255"/>
<tag k="maxspeed" v="30"/>
<tag k="maxspeed:zone" v="yes"/>
<ele k="maxspeed:zone" v="60"/>
<node id="25779114" lat="53.334062" lon="8.841545"/>
<node id="25779117" lat="53.338904" lon="8.84614"/>
<node id="25779110" lat="53.33795" lon="8.489255"/>
<tag k="maxspeed" v="32"/>
<tag k="maxspeed:zone" v="no"/>
</osm>

output:

1: D: MainClass -> main: @START_ELEMENT
2: D: MainClass -> main: getLocalName(): osm
3: D: MainClass -> main: getAttributeCount(): 0
4: D: MainClass -> main: @START_ELEMENT
5: D: MainClass -> main: getLocalName(): node
6: D: MainClass -> main: getAttributeCount(): 3
7: D: MainClass -> main: @END_ELEMENT
8: D: MainClass -> main: getText():node
9: D: MainClass -> main: @START_ELEMENT
10: D: MainClass -> main: getLocalName(): node
11: D: MainClass -> main: getAttributeCount(): 3
12: D: MainClass -> main: @END_ELEMENT
13: D: MainClass -> main: getText():node
14: D: MainClass -> main: @START_ELEMENT
15: D: MainClass -> main: getLocalName(): node
16: D: MainClass -> main: getAttributeCount(): 3
17: D: MainClass -> main: @END_ELEMENT
18: D: MainClass -> main: getText():node
...
...

Spring Integration Http Outbound Channel Adapter is discarding Header Params

<int:chain id="chain" input-channel="refundChannel" output-channel="nullChannel">
    <int:json-to-object-transformer object-mapper="jackson2JsonObjectMapper"/>
    <int:transformer ref="refundTransformer" method="transformToEntry"/>
    <int:transformer ref="marshallingTransformer" method="doTransform"/>
    <int:header-filter header-names="Content-Type,contentType,content_type,content-type,Accept,accept"/>
    <int:header-enricher>
        <int:header name="Accept" value="application/xml" overwrite="true"/>
        <int:header name="Content-Type" value="application/xml" overwrite="true"/>
        <int:header name="Authorization" value="Basic test" overwrite="true"/>
    </int:header-enricher>
    <int:service-activator ref="messageLogger" method="log"/>
    <int-http:outbound-gateway url="${url}refund" http-method="POST"
                               reply-timeout="20000" header-mapper="httpHeaderMapper" request-factory="bufferingRequestFactory"
                               expected-response-type="com.xxxxx.response.RefundResponse"/>
    <int:service-activator ref="messageLogger" method="log"/>
</int:chain>

As you see, I am getting JSON message from Channel and converting into Object and sending http request with xml type.

However when I receive response, Spring Integration is invoking json converter instead of xml unmarshaller and because of the same, I am getting error response.

I tried almost doing everything without success. Using Spring integration 4.1.2.RELEASE

Binding JQ grid with XML response coming from VB6 dll

I want to bind the JQgrid (in a Classic ASP page) with XML response I am getting from a VB6 COM .dll. All attempts to do so has failed so far unfortunately. I'd highly appreciate any help on this matter. Here is the that I have in my classic ASP page. All of the code is in one single .ASP file.

<script>
$(function () {
jQuery("#grid_top").jqGrid({
datatype: 'xmlstring',
datastr: strResponse, // 
pager: '#pager',
height: 250,
colNames:['Order ID','Segment', 'Terminal','Product','Delivered','Customer','Gross','Manifest ID','Notes'],
colModel:[
    {name:'OrderID',index:'orderId', width:100, xmlmap: function (obj) {
            return $(obj).attr('OrderId');}},
    {name:'Segment',index:'segment', width:60, xmlmap: function (obj) {
            return $(obj).attr('RouteSegment');}},
    {name:'Terminal',index:'terminal', width:100, xmlmap: function (obj) {
            return $(obj).attr('TerminalId');}},
    {name:'Product',index:'product', width:80, align:"right",xmlmap:  function (obj) {
            return $(obj).attr('ProductId');}},
    {name:'Delivered',index:'delivered', width:100, align:"right", xmlmap: function (obj) {
            return $(obj).attr('DeliveredTimestamp');}},        
    {name:'Customer',index:'customer', width:150,align:"right", xmlmap: function (obj) {
            return $(obj).attr('Customer');}},
    {name:'Gross',index:'gross', width:100, xmlmap: function (obj) {
            return $(obj).attr('Gross');}},
    {name:'Manifest ID',index:'gross', width:100, 
                xmlmap: function (obj) {
             return $(obj).attr('ManifestId');}},   
    {name:'Notes',index:'note', width:150, sortable:false}      
],
xmlReader: { root: "Data", row: "Row", repeatitems: false },
multiselect: true,
caption: "Deliver Orders for Route:"
 });

</script>  

Here is the code which is calling COM method

Dim strRequest :strRequest = "" strRequest = strRequest & " METHOD='FetchOrder'/>" objMSXML1.async = False objMSXML1.validateOnParse = True objMSXML1.setProperty "SelectionLanguage", "XPath" objMSXML1.loadXML strRequest strResponse = objManifest1.XMLDriver(CStr(strConnectionString1), objMSXML1.xml) %>

XML Format in (strResponse)

I am getting the XML response back from the COM method but I don't know how to bind this XML string to the JQGrid. What am I doing wrong here ? Highly appreciate any input...

How do I get the Magnolia empty webapp running with the Standard Templating Kit?

I'm having lots of trouble getting the Magnolia empty webapp project running, all related to Maven dependencies. It seems to be an extreme case of If you give a mouse a cookie, because every time I add a required dependency it throws an exception asking for another, and it's never enough.

I've been trying to follow this guide, which starts out using the Maven archetype command so it's not quite from scratch. The problem is that guide was written awhile back so the version numbers have changed a lot since then, and it seems the newest versions just aren't compatible with themselves.

Here's what my acme-project-webapp/pom.xml file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://ift.tt/IH78KX" xmlns:xsi="http://ift.tt/ra1lAU" xsi:schemaLocation="http://ift.tt/IH78KX http://ift.tt/HBk9RF">

    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.acme</groupId>
        <artifactId>acme-project</artifactId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <artifactId>acme-project-webapp</artifactId>
    <name>Acme Project: webapp</name>
    <packaging>war</packaging>

    <repositories>
        <repository>
            <id>magnolia-repo</id>
            <name>Magnolia Repository</name>
            <url>http://ift.tt/1MKklCr;
        </repository>
    </repositories>

   <dependencies>
    <dependency>
        <groupId>info.magnolia</groupId>
        <artifactId>magnolia-empty-webapp</artifactId>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>info.magnolia</groupId>
        <artifactId>magnolia-empty-webapp</artifactId>
        <type>war</type>
    </dependency>
    <dependency>
        <groupId>info.magnolia</groupId>
        <artifactId>magnolia-module-standard-templating-kit</artifactId>
        <version>2.9</version>
    </dependency>
    <dependency>
        <groupId>info.magnolia</groupId>
        <artifactId>magnolia-module-dms</artifactId>
        <version>1.6.9</version>
    </dependency>
    <dependency>
        <groupId>info.magnolia</groupId>
        <artifactId>magnolia-module-fckeditor</artifactId>
        <version>4.4.2</version>
    </dependency>
    <dependency>
        <groupId>info.magnolia</groupId>
        <artifactId>magnolia-module-mail</artifactId>
        <version>5.2.2</version>
    </dependency>
    <dependency>
        <groupId>info.magnolia</groupId>
        <artifactId>magnolia-imaging-support</artifactId>
        <version>3.2</version>
    </dependency>
</dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <dependentWarExcludes>WEB-INF/lib/*.jar</dependentWarExcludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

When I try to run the project, I get a host of exception messages. Here's what they say:

The following exceptions were found while checking Magnolia modules dependencies (i.e. those in META-INF/magnolia/my-module.xml): Module Magnolia JSP Templating Support Module (version 5.4.0) is dependent on templating (version 5.3/*), but Magnolia Templating Module (version 4.4.2) is currently installed.

Module Magnolia RSS Aggregator Module (version 2.4.0) is dependent on scheduler (version 2.2/*), but Magnolia Scheduler Module (version 2.1.1) is currently installed.

Module Magnolia RSS Aggregator Module (version 2.4.0) is dependent on mte (version 0.5/*), which was not found.

Module Magnolia DMS Module (version 1.6.9) is dependent on adminInterface (version 4.5.8/*), but Magnolia Admin Interface Module (version 4.4.2) is currently installed.

Module Magnolia DMS Module (version 1.6.9) is dependent on fckEditor (version 4.5.8/*), but Magnolia FCKEditor Module (version 4.4.2) is currently installed.

Module Magnolia DAM Templating (version 2.1.0) is dependent on templating (version 5.4/* - optional), but Magnolia Templating Module (version 4.4.2) is currently installed.

Module Magnolia Standard Templating Kit Module (version 2.9.0) is dependent on templating (version 5.3/*), but Magnolia Templating Module (version 4.4.2) is currently installed.

Module Magnolia Standard Templating Kit Module (version 2.9.0) is dependent on adminInterface (version 5.2/*), but Magnolia Admin Interface Module (version 4.4.2) is currently installed.

Module Inplace Templating Module (version 2.4.0) is dependent on templating (version 5.4/*), but Magnolia Templating Module (version 4.4.2) is currently installed.

Module Magnolia Public User Registration Module (version 2.4.3) is dependent on templating (version 5.3/*), but Magnolia Templating Module (version 4.4.2) is currently installed.

Module Magnolia 4.5 Migration Module (version 1.2.4) is dependent on adminInterface (version 4.5.10/*), but Magnolia Admin Interface Module (version 4.4.2) is currently installed.

Module Magnolia Resources Module (version 2.4.0) is dependent on templating (version 5.4/*), but Magnolia Templating Module (version 4.4.2) is currently installed.

Module Magnolia Module Forum (version 3.4.6) is dependent on adminInterface (version 5.0.2/*), but Magnolia Admin Interface Module (version 4.4.2) is currently installed.

Module Magnolia Site Module (version 1.0.0) is dependent on templating (version 5.4/*), but Magnolia Templating Module (version 4.4.2) is currently installed.

Module Magnolia Form Module (version 2.2.12) is dependent on templating (version 5.2.2/*), but Magnolia Templating Module (version 4.4.2) is currently installed.

At first I would get messages saying dependencies were not found (in addition to the version mismatches), and so whenever I saw those I would try adding in the missing dependencies one by one. But it's been a long rabbit hole I've been falling down.

Fundamentally I don't really care about all these nested dependencies that it seems to require; all I really want is to get this running with the Standard Templating Kit, and once that's in place, with the Jackrabbit Persistence Manager (so I can use MySQL). Why is this so hard to get running out of the box? How do I even get it running in the first place?

Uber Uploader XML ERROR: XML_ERR_NAME_REQUIRED at line 1 with hwdMediaShare

Uber uploader was working perfectly, and then suddenly it doesn't work and has this error:

XML ERROR: XML_ERR_NAME_REQUIRED at line 1

It occasionally starts working again and then goes back to this problem.

Error in code as3?

I have a folder contains swf and xml files.

This is my AS3 code :

import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;

function loadMyswf(url:String):void {
    var myswf:Loader = new Loader();
    var url2:URLRequest = new URLRequest("");
    myswf.load(url2);
    addChild(myswf);  
}

I try to load an swf file using a Loader ( myswf ) when the user click on the AccordionTreeMenu V3 component, but that is not working.

So, what is wrong with my code ?

Error creating bean 'entityManagerFactory' defined in ServletContext resource: Unable to build Hibernate SessionFactory

I have been wrestling with this project now for few days and I am at a complete loss shooting in the dark. I have followed too many tutorials and still cannot get this to cooperate. I had this "working" for a bit but later came to find out that my setup did not allow for me to take advantage of repositories. So I had to take a few steps backward. Lately, I started using a hibernate.cfg.xml that has been replaced with persistance.xml but still no luck. Thanks ahead of time.

persistance.xml:

<persistence xmlns="http://ift.tt/UICAJV"
         xmlns:xsi="http://ift.tt/ra1lAU"
         xsi:schemaLocation="http://ift.tt/UICAJV http://ift.tt/O9YdEP"
         version="2.0">
<persistence-unit name="sample" transaction-type="RESOURCE_LOCAL">
    <class>com.test.sms.models.SmsMessage</class>
    <properties>
        <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
        <property name="hibernate.connection.password" value="password"/>
        <property name="hibernate.connection.url" value="jdbc:http://sqlserverMasterDb0;database=SMS_SERVICE"/>
        <property name="hibernate.connection.username" value="username"/>
        <property name="hibernate.default_schema" value="SMS_SERVICE"/>
        <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
    </properties>
</persistence-unit>

sevlet.xml

<beans xmlns="http://ift.tt/GArMu6"
   xmlns:xsi="http://ift.tt/ra1lAU"
   xmlns:mvc="http://ift.tt/1bHqwjR"
   xmlns:context="http://ift.tt/GArMu7"
   xmlns:jpa="http://ift.tt/1iMF6wA"
   xsi:schemaLocation="http://ift.tt/GArMu6
    http://ift.tt/1jdM0fG
    http://ift.tt/1bHqwjR http://ift.tt/1fmimld http://ift.tt/GArMu7 http://ift.tt/1jdLYo7
    http://ift.tt/1iMF6wA
    http://ift.tt/1jZdjKs">

<mvc:annotation-driven/>
<context:annotation-config/>
<context:component-scan base-package="com.test.sms"/>
<jpa:repositories base-package="com.test.sms.models.repository"/>

<bean id="jsonMessageConverter" class="org.springframework.http.converter.json.GsonHttpMessageConverter"/>
<bean name="handlerMapping"
      class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>

<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
    <property name="messageConverters">
        <list>
            <ref bean="jsonMessageConverter"/>
        </list>
    </property>
</bean>

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>
    <property name="url" value="jdbc:http://sqlserverMasterDb0;database=SMS_SERVICE"/>
    <property name="username" value="username"/>
    <property name="password" value="password"/>
</bean>

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="packagesToScan" value="com.test.sms"/>
    <property name="jpaVendorAdapter">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
    </property>
    <property name="jpaProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
        </props>
    </property>
</bean>

<!-- Configure the transaction manager bean -->
<bean id="transactionManager"
      class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>

pom.xml

<project xmlns="http://ift.tt/IH78KX" xmlns:xsi="http://ift.tt/ra1lAU"
     xsi:schemaLocation="http://ift.tt/IH78KX http://ift.tt/HBk9RF">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.sms</groupId>
<artifactId>SMSService</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>SMSService</name>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.2.5.RELEASE</version>
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
    </dependency>
    <!-- Spring dependencies -->
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-dao</artifactId>
        <version>2.0.8</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${spring.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <!-- Non-Spring dependencies -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
    </dependency>

    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5</version>
    </dependency>

    <dependency>
        <groupId>com.twilio.sdk</groupId>
        <artifactId>twilio-java-sdk</artifactId>
        <version>4.4.4</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

    <dependency>
        <groupId>org.jmockit</groupId>
        <artifactId>jmockit</artifactId>
        <version>1.18</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>net.sourceforge.jtds</groupId>
        <artifactId>com.springsource.net.sourceforge.jtds</artifactId>
        <version>1.2.2</version>
    </dependency>

    <dependency>
        <groupId>com.tngtech.java</groupId>
        <artifactId>junit-dataprovider</artifactId>
        <version>1.9.4</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.3.1</version>
    </dependency>
</dependencies>

<build>
    <finalName>SMSService</finalName>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <mainClass>com.test.sms</mainClass>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
                <includes>
                    <include>**/*Tests.java</include>
                </includes>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
            </configuration>
        </plugin>
    </plugins>
</build>

<repositories>
    <repository>
        <id>spring-releases</id>
        <name>Spring Releases</name>
        <url>http://ift.tt/1A9iaEo;
    </repository>
    <repository>
        <id>org.jboss.repository.releases</id>
        <name>JBoss Maven Release Repository</name>
        <url>http://ift.tt/NpWKvb;
    </repository>
</repositories>

<pluginRepositories>
    <pluginRepository>
        <id>spring-releases</id>
        <name>Spring Releases</name>
        <url>http://ift.tt/1A9iaEo;
    </pluginRepository>
</pluginRepositories>

Stack Trace:

08:05:20.398 [http-bio-8164-exec-5] INFO  o.s.o.j.LocalContainerEntityManagerFactoryBean - Building JPA container EntityManagerFactory for persistence unit 'default'
08:05:20.411 [http-bio-8164-exec-5] DEBUG o.s.j.d.DriverManagerDataSource - Creating new JDBC DriverManager Connection to [jdbc:http://sqlserverMasterDb0;database=SMS_SERVICE]
08:05:20.419 [http-bio-8164-exec-5] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Retrieved dependent beans for bean 'org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter#3fbdd602': [entityManagerFactory]
08:05:20.420 [http-bio-8164-exec-5] WARN  o.s.w.c.s.XmlWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/SMSService-servlet.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956) ~[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:747) ~[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) ~[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:664) [spring-webmvc-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:630) [spring-webmvc-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:678) [spring-webmvc-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:549) [spring-webmvc-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:490) [spring-webmvc-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) [spring-webmvc-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at javax.servlet.GenericServlet.init(GenericServlet.java:158) [servlet-api.jar:3.0.FR]
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284) [catalina.jar:7.0.63]
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197) [catalina.jar:7.0.63]
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:864) [catalina.jar:7.0.63]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:134) [catalina.jar:7.0.63]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) [catalina.jar:7.0.63]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) [catalina.jar:7.0.63]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) [catalina.jar:7.0.63]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) [catalina.jar:7.0.63]
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957) [catalina.jar:7.0.63]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) [catalina.jar:7.0.63]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423) [catalina.jar:7.0.63]
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079) [tomcat-coyote.jar:7.0.63]
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620) [tomcat-coyote.jar:7.0.63]
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) [tomcat-coyote.jar:7.0.63]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_31]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_31]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-coyote.jar:7.0.63]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_31]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1249) ~[hibernate-entitymanager-4.3.10.Final.jar:4.3.10.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.access$600(EntityManagerFactoryBuilderImpl.java:120) ~[hibernate-entitymanager-4.3.10.Final.jar:4.3.10.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:860) ~[hibernate-entitymanager-4.3.10.Final.jar:4.3.10.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850) ~[hibernate-entitymanager-4.3.10.Final.jar:4.3.10.Final]
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849) ~[hibernate-entitymanager-4.3.10.Final.jar:4.3.10.Final]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343) ~[spring-orm-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318) ~[spring-orm-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    ... 34 common frames omitted
Caused by: org.hibernate.AnnotationException: Cannot find the expected secondary table: no smsUser available for com.test.sms.models.database.SmsMessage
    at org.hibernate.cfg.Ejb3Column.getJoin(Ejb3Column.java:416) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
    at org.hibernate.cfg.Ejb3Column.getTable(Ejb3Column.java:397) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
    at org.hibernate.cfg.AnnotationBinder.bindManyToOne(AnnotationBinder.java:2829) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
    at org.hibernate.cfg.AnnotationBinder.bindOneToOne(AnnotationBinder.java:3051) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
    at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1839) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
    at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:963) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
    at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:796) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
    at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3845) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
    at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3799) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
    at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1412) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857) ~[hibernate-entitymanager-4.3.10.Final.jar:4.3.10.Final]
    ... 42 common frames omitted
08:05:20.421 [http-bio-8164-exec-5] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@792116a0: defining beans [mvcContentNegotiationManager,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean#0,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0,mvcUriComponentsContributor,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#0,org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#0,org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver#0,org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,sendController,messageValidator,org.springframework.data.jpa.repository.config.JpaRepositoryConfigExtension#0,org.springframework.data.repository.core.support.RepositoryInterfaceAwareBeanPostProcessor,foo,jpaMappingContext,smsMessageRepository,smsUserRepository,jsonMessageConverter,handlerMapping,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#1,dataSource,entityManagerFactory,transactionManager,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor,org.springframework.orm.jpa.SharedEntityManagerCreator#0]; root of factory hierarchy
08:05:20.421 [http-bio-8164-exec-5] ERROR o.s.web.servlet.DispatcherServlet - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/SMSService-servlet.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956) ~[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:747) ~[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) ~[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:664) ~[spring-webmvc-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:630) ~[spring-webmvc-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:678) ~[spring-webmvc-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:549) ~[spring-webmvc-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:490) ~[spring-webmvc-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) [spring-webmvc-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at javax.servlet.GenericServlet.init(GenericServlet.java:158) [servlet-api.jar:3.0.FR]
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284) [catalina.jar:7.0.63]
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197) [catalina.jar:7.0.63]
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:864) [catalina.jar:7.0.63]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:134) [catalina.jar:7.0.63]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) [catalina.jar:7.0.63]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) [catalina.jar:7.0.63]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) [catalina.jar:7.0.63]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) [catalina.jar:7.0.63]
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957) [catalina.jar:7.0.63]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) [catalina.jar:7.0.63]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423) [catalina.jar:7.0.63]
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079) [tomcat-coyote.jar:7.0.63]
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620) [tomcat-coyote.jar:7.0.63]
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) [tomcat-coyote.jar:7.0.63]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_31]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_31]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-coyote.jar:7.0.63]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_31]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1249) ~[hibernate-entitymanager-4.3.10.Final.jar:4.3.10.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.access$600(EntityManagerFactoryBuilderImpl.java:120) ~[hibernate-entitymanager-4.3.10.Final.jar:4.3.10.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:860) ~[hibernate-entitymanager-4.3.10.Final.jar:4.3.10.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850) ~[hibernate-entitymanager-4.3.10.Final.jar:4.3.10.Final]
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849) ~[hibernate-entitymanager-4.3.10.Final.jar:4.3.10.Final]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343) ~[spring-orm-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at 

XPathEvaluator in Firefox addon

I am attempting to follow this article to evaluate an XPath expression. My code is copy/pasted from the article:

// Evaluate an XPath expression aExpression against a given DOM node
// or Document object (aNode), returning the results as an array
// thanks wanderingstan at morethanwarm dot mail dot com for the
// initial work.
function evaluateXPath(aNode, aExpr) {
  var xpe = new XPathEvaluator();
  var nsResolver = xpe.createNSResolver(aNode.ownerDocument == null ?
    aNode.documentElement : aNode.ownerDocument.documentElement);
  var result = xpe.evaluate(aExpr, aNode, nsResolver, 0, null);
  var found = [];
  var res;
  while (res = result.iterateNext())
    found.push(res);
  return found;
}

However, I'm getting this error:

Message: ReferenceError: XPathEvaluator is not defined

Is Mozilla's article out of date, perhaps? Is there a more up-to-date article available on parsing XML in an SDK add-on?

Edit. When I tried it this way:

var {Cc, Ci} = require("chrome");
var domXPathEvaluator = Cc["@http://ift.tt/1II9uXP"].createInstance(Ci.nsIDOMXPathEvaluator);

I got a long error message:

- message = Component returned failure code: 0x80570019 (NS_ERROR_XPC_CANT_CREATE_WN) [nsIJSCID.createInstance]
- fileName = undefined
- lineNumber = 14
- stack = @undefined:14:undefined|@http://resourcehelloworld-addon/index.js:14:25|run@resourcegre/modules/commonjs/sdk/addon/runner.js:145:19|startup/</<@resourcegre/modules/commonjs/sdk/addon/runner.js:86:7|Handler.prototype.process@resourcegre/modules/Promise-backend.js:920:23|this.PromiseWalker.walkerLoop@resourcegre/modules/Promise-backend.js:799:7|this.PromiseWalker.scheduleWalkerLoop/<@resourcegre/modules/Promise-backend.js:738:39|Promise*this.PromiseWalker.scheduleWalkerLoop@resourcegre/modules/Promise-backend.js:738:7|this.PromiseWalker.schedulePromise@resourcegre/modules/Promise-backend.js:762:7|this.PromiseWalker.completePromise@resourcegre/modules/Promise-backend.js:705:7|handler@resourcegre/modules/commonjs/sdk/addon/window.js:56:3|
- toString = function () /* use strict */ toString

Dynamically add ImageButtons

I have to dynamically create ImageButtons for an Array of images after a network call is completed. I currently have it working with the amount of buttons hardcoded, but the amount of buttons will be dynamically added and removed on the server.

The XML Code is below this works as its hardcoded:

<LinearLayout xmlns:android="http://ift.tt/nIICcg"
          xmlns:tools="http://ift.tt/LrGmb4"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="horizontal"
          android:weightSum="1"
          tools:background="@color/black"
android:id="@+id/dotw_list">

<ImageButton
    android:id="@+id/dotw_imageButton_1"
    android:layout_width="60dp"
    android:layout_height="60dp"
    android:layout_marginBottom="10dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="10dp"
    android:adjustViewBounds="false"
    android:background="@drawable/layout_bg"
    android:padding="5dp"
    android:scaleType="centerInside"/>

<ImageButton
    android:id="@+id/dotw_imageButton_2"
    android:layout_width="60dp"
    android:layout_height="60dp"
    android:layout_marginBottom="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="10dp"
    android:adjustViewBounds="false"
    android:background="@drawable/layout_bg"
    android:padding="10dp"
    android:scaleType="centerInside"/>

<ImageButton
    android:id="@+id/dotw_imageButton_3"
    android:layout_width="60dp"
    android:layout_height="60dp"
    android:layout_marginBottom="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="10dp"
    android:adjustViewBounds="false"
    android:background="@drawable/layout_bg"
    android:padding="10dp"
    android:scaleType="centerInside"/>

<ImageButton
    android:id="@+id/dotw_imageButton_4"
    android:layout_width="60dp"
    android:layout_height="60dp"
    android:layout_marginBottom="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="10dp"
    android:adjustViewBounds="false"
    android:background="@drawable/layout_bg"
    android:padding="10dp"
    android:scaleType="centerInside"/>

<ImageButton
    android:id="@+id/dotw_imageButton_5"
    android:layout_width="60dp"
    android:layout_height="60dp"
    android:layout_marginBottom="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="10dp"
    android:adjustViewBounds="false"
    android:background="@drawable/layout_bg"
    android:padding="10dp"
    android:scaleType="centerInside"/>
</LinearLayout>

Below is the code I have used to hard code it but i need this to be dynamically changed when there are more/less items in the Array

private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {

    // Get extra data included in the Intent
    String message = intent.getStringExtra("network_response");
    Log.d("receiver", "Got message: " + message);

    home = data.getHomeItem();


    try {
        for (int i = 0; i < home.dotwItemArray.size(); i++) {
            System.out.println("Size of DOTW Array for the home screen is " + home.dotwItemArray.size());

            DotwItem dotwItem = home.dotwItemArray.get(i);

            if (i == 0) {
                request.getImage(dotwItem.getThumbnailImageUrl(), button_dotw_1);
                System.out.println("dotwItem1 is set");
            }
            if (i == 1) {
                request.getImage(dotwItem.getThumbnailImageUrl(), button_dotw_2);
                System.out.println("dotwItem2 is set");
            }
            if (i == 2) {
                request.getImage(dotwItem.getThumbnailImageUrl(), button_dotw_3);
                System.out.println("dotwItem3 is set");
            }
            if (i == 3) {
                request.getImage(dotwItem.getThumbnailImageUrl(), button_dotw_4);
                System.out.println("dotwItem4 is set");
            }
        }

    } catch (Exception e) {
        System.out.println("Error is: " + e + " - Exception is it: " + e.getStackTrace()[2].getLineNumber());

    }
}
};

The reason I am doing this, is because I dont know the length of the Array that I am getting until the network call is complete. The network call is initiated in the onCreate method and as you can see this is in the onReceive method, this method is initiated once the network call is completed.

I had a look at this link from StackOverflow but Im a little confused as I am trying to set the image based on the network request.

Thanks