问:
Ask user to turn on Location
How can I prompt the user to turn on Location?

The app is supposed to filter a list of locations with the current location of the user. If the user has the Location service turned off, the app should prompt the user asking for the Location to be turned on.

For instance Trip Advisor app does this:

( Not sure if I can post other apps screenshots here, but if I shouldn't be doing it, please say so. And apologize for the full sized images, tried to make them smaller, but SO didn't liked it... )

In the first image, you can see I have the Location service turned off. The, after opening the Trip Advisor app, and tapping the Near me now option, I'm prompted with the second image, where I'm asked to Turn on Location services. After I tap the button, a dialog shows up so I can allow, or disallow, the Location service to be turned on. If I tap OK, the Location service is turned on on the device, and the app consumes it.

How can I achieve this?

答:
Suppose your are doing all this stuff in an Activity name LocationActivity. You need to implement some callbacks for this purpose. Below is the code with comments so you can easily understand which method do what and when is called.

Keep in mind to add permissions in app manifest file:

```<code><uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</code>```

Code for Ativity:

```<code>import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.v13.app.ActivityCompat;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.LocationSettingsRequest;
import com.google.android.gms.location.LocationSettingsResult;
import com.google.android.gms.location.LocationSettingsStatusCodes;

public class LocationActivity extends FragmentActivity implements GoogleApiClient.ConnectionCallbacks,
        GoogleApiClient.OnConnectionFailedListener {

    // Unique tag for the error dialog fragment
    private static final String DIALOG_ERROR = "dialog_error";
    // Bool to track whether the app is already resolving an error
    private boolean mResolvingError = false;
    // Request code to use when launching the resolution activity
    private static final int REQUEST_RESOLVE_ERROR = 555;

    int ACCESS_FINE_LOCATION_CODE = 3310;
    int ACCESS_COARSE_LOCATION_CODE = 3410;
    private GoogleApiClient mGoogleApiClient;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Build Google API Client for Location related work
        buildGoogleApiClient();
    }

    // When user first come to this activity we try to connect Google services for location and map related work
    protected synchronized void buildGoogleApiClient() {
        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(LocationServices.API)
                .build();
    }

    // Google Api Client is connected
    @Override
    public void onConnected(Bundle bundle) {
        if (mGoogleApiClient.isConnected()) {
            //if connected successfully show user the settings dialog to enable location from settings services
            // If location services are enabled then get Location directly
            // Else show options for enable or disable location services
            settingsrequest();
        }
    }

    // This is the method that will be called if user has disabled the location services in the device settings
    // This will show a dialog asking user to enable location services or not
    // If user tap on "Yes" it will directly enable the services without taking user to the device settings
    // If user tap "No" it will just Finish the current Activity
    public void settingsrequest() {
        LocationRequest locationRequest = LocationRequest.create();
        locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
        locationRequest.setInterval(30 * 1000);
        locationRequest.setFastestInterval(5 * 1000);
        LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest);
        builder.setAlwaysShow(true); //this is the key ingredient

        PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());
        result.setResultCallback(new ResultCallback<LocationSettingsResult>() {
            @Override
            public void onResult(LocationSettingsResult result) {
                final Status status = result.getStatus();
                switch (status.getStatusCode()) {
                    case LocationSettingsStatusCodes.SUCCESS:
                        if (mGoogleApiClient.isConnected()) {

                            // check if the device has OS Marshmellow or greater than
                            if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
                                if (ActivityCompat.checkSelfPermission(LocationActivity.this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(LocationActivity.this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                                    ActivityCompat.requestPermissions(LocationActivity.this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, ACCESS_FINE_LOCATION_CODE);
                                } else {
                                    // get Location
                                }
                            } else {
                                // get Location
                            }

                        }
                        break;
                    case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
                        // Location settings are not satisfied. But could be fixed by showing the user
                        // a dialog.
                        try {
                            // Show the dialog by calling startResolutionForResult(),
                            // and check the result in onActivityResult().
                            status.startResolutionForResult(LocationActivity.this, REQUEST_RESOLVE_ERROR);
                        } catch (IntentSender.SendIntentException e) {
                            // Ignore the error.
                        }
                        break;
                    case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
                        // Location settings are not satisfied. However, we have no way to fix the
                        // settings so we won't show the dialog.
                        break;
                }
            }
        });
    }

    // This method is called only on devices having installed Android version >= M (Marshmellow)
    // This method is just to show the user options for allow or deny location services at runtime
    @Override
    public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
        switch (requestCode) {
            case 3310: {

                if (grantResults.length > 0) {

                    for (int i = 0, len = permissions.length; i < len; i++) {

                        if (grantResults[i] == PackageManager.PERMISSION_DENIED) {
                            // Show the user a dialog why you need location
                        } else if (grantResults[i] == PackageManager.PERMISSION_GRANTED) {
                            // get Location
                        } else {
                            this.finish();
                        }
                    }
                }
                return;
            }
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == REQUEST_RESOLVE_ERROR) {
            mResolvingError = false;
            switch (resultCode) {
                case Activity.RESULT_OK:
                    // get location method
                    break;
                case Activity.RESULT_CANCELED:
                    this.finish();
                    break;
            }
        }
    }

    @Override
    public void onConnectionSuspended(int i) {
    }

    // When there is an error connecting Google Services
    @Override
    public void onConnectionFailed(ConnectionResult result) {
        if (mResolvingError) {
            // Already attempting to resolve an error.
            return;
        } else if (result.hasResolution()) {
            try {
                mResolvingError = true;
                result.startResolutionForResult(this, REQUEST_RESOLVE_ERROR);
            } catch (IntentSender.SendIntentException e) {
                // There was an error with the resolution intent. Try again.
                mGoogleApiClient.connect();
            }
        } else {
            // Show dialog using GoogleApiAvailability.getErrorDialog()
            showErrorDialog(result.getErrorCode());
            mResolvingError = true;
        }
    }

    /* Creates a dialog for an error message */
    private void showErrorDialog(int errorCode) {
        // Create a fragment for the error dialog
        ErrorDialogFragment dialogFragment = new ErrorDialogFragment();
        // Pass the error that should be displayed
        Bundle args = new Bundle();
        args.putInt(DIALOG_ERROR, errorCode);
        dialogFragment.setArguments(args);
        dialogFragment.show(getSupportFragmentManager(), "errordialog");
    }

    /* Called from ErrorDialogFragment when the dialog is dismissed. */
    public void onDialogDismissed() {
        mResolvingError = false;
    }

    /* A fragment to display an error dialog */
    public static class ErrorDialogFragment extends DialogFragment {
        public ErrorDialogFragment() {
        }

        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            // Get the error code and retrieve the appropriate dialog
            int errorCode = this.getArguments().getInt(DIALOG_ERROR);
            return GoogleApiAvailability.getInstance().getErrorDialog(
                    this.getActivity(), errorCode, REQUEST_RESOLVE_ERROR);
        }

        @Override
        public void onDismiss(DialogInterface dialog) {
            ((LocationActivity) getActivity()).onDialogDismissed();
        }
    }

    // Connect Google Api Client if it is not connected already
    @Override
    protected void onStart() {
        super.onStart();
        if (mGoogleApiClient != null) {
            mGoogleApiClient.connect();
        }
    }

    // Stop the service when we are leaving this activity
    @Override
    protected void onStop() {
        super.onStop();
        if (mGoogleApiClient != null) {
            mGoogleApiClient.disconnect();
        }
    }

}
</code>```

You can read the official docs here

Title: Ask user to turn on Location

Body:
Suppose your are doing all this stuff in an Activity name LocationActivity. You need to implement some callbacks for this purpose. Below is the code with comments so you can easily understand which method do what and when is called.

Keep in mind to add permissions in app manifest file:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

Code for Ativity:

import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.v13.app.ActivityCompat;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.LocationSettingsRequest;
import com.google.android.gms.location.LocationSettingsResult;
import com.google.android.gms.location.LocationSettingsStatusCodes;

public class LocationActivity extends FragmentActivity implements GoogleApiClient.ConnectionCallbacks,
        GoogleApiClient.OnConnectionFailedListener {

    // Unique tag for the error dialog fragment
    private static final String DIALOG_ERROR = "dialog_error";
    // Bool to track whether the app is already resolving an error
    private boolean mResolvingError = false;
    // Request code to use when launching the resolution activity
    private static final int REQUEST_RESOLVE_ERROR = 555;

    int ACCESS_FINE_LOCATION_CODE = 3310;
    int ACCESS_COARSE_LOCATION_CODE = 3410;
    private GoogleApiClient mGoogleApiClient;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Build Google API Client for Location related work
        buildGoogleApiClient();
    }

    // When user first come to this activity we try to connect Google services for location and map related work
    protected synchronized void buildGoogleApiClient() {
        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(LocationServices.API)
                .build();
    }

    // Google Api Client is connected
    @Override
    public void onConnected(Bundle bundle) {
        if (mGoogleApiClient.isConnected()) {
            //if connected successfully show user the settings dialog to enable location from settings services
            // If location services are enabled then get Location directly
            // Else show options for enable or disable location services
            settingsrequest();
        }
    }

    // This is the method that will be called if user has disabled the location services in the device settings
    // This will show a dialog asking user to enable location services or not
    // If user tap on "Yes" it will directly enable the services without taking user to the device settings
    // If user tap "No" it will just Finish the current Activity
    public void settingsrequest() {
        LocationRequest locationRequest = LocationRequest.create();
        locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
        locationRequest.setInterval(30 * 1000);
        locationRequest.setFastestInterval(5 * 1000);
        LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest);
        builder.setAlwaysShow(true); //this is the key ingredient

        PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());
        result.setResultCallback(new ResultCallback<LocationSettingsResult>() {
            @Override
            public void onResult(LocationSettingsResult result) {
                final Status status = result.getStatus();
                switch (status.getStatusCode()) {
                    case LocationSettingsStatusCodes.SUCCESS:
                        if (mGoogleApiClient.isConnected()) {

                            // check if the device has OS Marshmellow or greater than
                            if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
                                if (ActivityCompat.checkSelfPermission(LocationActivity.this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(LocationActivity.this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                                    ActivityCompat.requestPermissions(LocationActivity.this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, ACCESS_FINE_LOCATION_CODE);
                                } else {
                                    // get Location
                                }
                            } else {
                                // get Location
                            }

                        }
                        break;
                    case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
                        // Location settings are not satisfied. But could be fixed by showing the user
                        // a dialog.
                        try {
                            // Show the dialog by calling startResolutionForResult(),
                            // and check the result in onActivityResult().
                            status.startResolutionForResult(LocationActivity.this, REQUEST_RESOLVE_ERROR);
                        } catch (IntentSender.SendIntentException e) {
                            // Ignore the error.
                        }
                        break;
                    case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
                        // Location settings are not satisfied. However, we have no way to fix the
                        // settings so we won't show the dialog.
                        break;
                }
            }
        });
    }

    // This method is called only on devices having installed Android version >= M (Marshmellow)
    // This method is just to show the user options for allow or deny location services at runtime
    @Override
    public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
        switch (requestCode) {
            case 3310: {

                if (grantResults.length > 0) {

                    for (int i = 0, len = permissions.length; i < len; i++) {

                        if (grantResults[i] == PackageManager.PERMISSION_DENIED) {
                            // Show the user a dialog why you need location
                        } else if (grantResults[i] == PackageManager.PERMISSION_GRANTED) {
                            // get Location
                        } else {
                            this.finish();
                        }
                    }
                }
                return;
            }
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == REQUEST_RESOLVE_ERROR) {
            mResolvingError = false;
            switch (resultCode) {
                case Activity.RESULT_OK:
                    // get location method
                    break;
                case Activity.RESULT_CANCELED:
                    this.finish();
                    break;
            }
        }
    }

    @Override
    public void onConnectionSuspended(int i) {
    }

    // When there is an error connecting Google Services
    @Override
    public void onConnectionFailed(ConnectionResult result) {
        if (mResolvingError) {
            // Already attempting to resolve an error.
            return;
        } else if (result.hasResolution()) {
            try {
                mResolvingError = true;
                result.startResolutionForResult(this, REQUEST_RESOLVE_ERROR);
            } catch (IntentSender.SendIntentException e) {
                // There was an error with the resolution intent. Try again.
                mGoogleApiClient.connect();
            }
        } else {
            // Show dialog using GoogleApiAvailability.getErrorDialog()
            showErrorDialog(result.getErrorCode());
            mResolvingError = true;
        }
    }

    /* Creates a dialog for an error message */
    private void showErrorDialog(int errorCode) {
        // Create a fragment for the error dialog
        ErrorDialogFragment dialogFragment = new ErrorDialogFragment();
        // Pass the error that should be displayed
        Bundle args = new Bundle();
        args.putInt(DIALOG_ERROR, errorCode);
        dialogFragment.setArguments(args);
        dialogFragment.show(getSupportFragmentManager(), "errordialog");
    }

    /* Called from ErrorDialogFragment when the dialog is dismissed. */
    public void onDialogDismissed() {
        mResolvingError = false;
    }

    /* A fragment to display an error dialog */
    public static class ErrorDialogFragment extends DialogFragment {
        public ErrorDialogFragment() {
        }

        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            // Get the error code and retrieve the appropriate dialog
            int errorCode = this.getArguments().getInt(DIALOG_ERROR);
            return GoogleApiAvailability.getInstance().getErrorDialog(
                    this.getActivity(), errorCode, REQUEST_RESOLVE_ERROR);
        }

        @Override
        public void onDismiss(DialogInterface dialog) {
            ((LocationActivity) getActivity()).onDialogDismissed();
        }
    }

    // Connect Google Api Client if it is not connected already
    @Override
    protected void onStart() {
        super.onStart();
        if (mGoogleApiClient != null) {
            mGoogleApiClient.connect();
        }
    }

    // Stop the service when we are leaving this activity
    @Override
    protected void onStop() {
        super.onStop();
        if (mGoogleApiClient != null) {
            mGoogleApiClient.disconnect();
        }
    }

}

You can read the official docs here


来源: stackexchange

问:
How do I get a token to use Google Cloud (Container Engine JSON API)?
I just want to create an OAuth token that I can use when accessing the Container Engine service. But the docs are hopeless in this regard.

Could somebody explain how to generate a token? Every other REST service I've ever used gives me a way of clicking a button and obtaining a token.

NOTE: Must not require installing any proprietary software, e.g. the Google SDK.

答:
omg, that was so painful to discover. But eventually I fumbled into this:

https://console.developers.google.com/apis/credentials?project=projectId

(replace projectId with the value for your setup)

which lets you generate an API key.

ContentLicense: CC BY-SA 3.0


问:
JSTL solution for providing space between capital letters
Is there any way to provide space between Capital Letters.

```<code>Eg. I have a jstl expression ${platName} which outputs  AmazonEcho

What I need as output is  Amazon Echo.
</code>```

I tried a few jstl functions but it didn`t help.

答:
Thanks, this worked</p>

```<code>${platName.replaceAll("(\\p{Ll})(\\p{Lu})","$1 $2")}
</code>```

Body:
Is there any way to provide space between Capital Letters.

Eg. I have a jstl expression ${platName} which outputs  AmazonEcho

What I need as output is  Amazon Echo.

I tried a few jstl functions but it didn`t help.

Body:
Thanks, this worked

${platName.replaceAll("(\\p{Ll})(\\p{Lu})","$1 $2")}


问:
Reference binding and the copy constructor/move constructor
If I have a function like so:

```<code>int foo(std::vector<int>* integer1ArrayIn, * integer2ArrayIn) {
    std::vector<int>& integer1Array = *integer1ArrayIn;
    std::vector<int>& integer2Array = *integer2ArrayIn;
}
</code>```

Will the reference integer1Array be calling a copy constructor/move constructor to copy over the elements of the passed in parameter?

Does binding a reference to a dereferenced pointer call the copy constructor?

In what circumstances does reference binding invoke a copy constructor?

Can someone explain what happens as this code executes in memory?

Thank you

答:
1) No, there are no copies made. You can test it with a small program, like this.

```<code>#include <iostream>

struct foo
{
    foo() { std::cout << "Constructor" << std::endl; }
    foo(const foo&) { std::cout << "Copy constructor" << std::endl; }
    foo& operator=(const foo&) { std::cout << "Copy assignment operator" << std::endl; }
};

int main() {
    foo* A = new foo;
    foo& B = *A;
    delete A;
}
</code>```

2) Beware of nullptrs! Otherwise all is fine.

3) Never (see answer by AlexG)

4) Not sure what you mean by "code executes in memory", since code is not executed in memory. If you mean what happens to the memory when the program is executed, then that's another story

Body:
If I have a function like so:

int foo(std::vector<int>* integer1ArrayIn, * integer2ArrayIn) {
    std::vector<int>& integer1Array = *integer1ArrayIn;
    std::vector<int>& integer2Array = *integer2ArrayIn;
}

Will the reference integer1Array be calling a copy constructor/move constructor to copy over the elements of the passed in parameter?

Does binding a reference to a dereferenced pointer call the copy constructor?

In what circumstances does reference binding invoke a copy constructor?

Can someone explain what happens as this code executes in memory?

Thank you

Body:
1) No, there are no copies made. You can test it with a small program, like this.

#include <iostream>

struct foo
{
    foo() { std::cout << "Constructor" << std::endl; }
    foo(const foo&) { std::cout << "Copy constructor" << std::endl; }
    foo& operator=(const foo&) { std::cout << "Copy assignment operator" << std::endl; }
};

int main() {
    foo* A = new foo;
    foo& B = *A;
    delete A;
}

2) Beware of nullptrs! Otherwise all is fine.

3) Never (see answer by AlexG)

4) Not sure what you mean by "code executes in memory", since code is not executed in memory. If you mean what happens to the memory when the program is executed, then that's another story


问:
How do I get different values from the same variable in XML using XSL
XML:

```<code><message code="100" description="checkSnr">
  <string name="id"/>
  <string name="serialNr"/>
</message>
</code>```

XSL:

```<code><xsl:template match="/">
  <xsl:for-each select="machine/events">
    <xsl:text>;</xsl:text>
    <xsl:value-of select="message/@code"/>
    <xsl:text>;</xsl:text>
    <xsl:value-of select="message/string/@name"  />
    <xsl:text>;</xsl:text>
    <xsl:value-of select="message/string/@name"  />
  </xsl:for-each>
</xsl:template>
</code>```

So here's my Problem. My XSL-File is supposed to detect the value "id" and the value "serialNr", but my Output is "id" x2. I know it is only Logical but how can I actually Change my XSL so it gives me both of the values? (by the way, in the XML there are parts, where the variable "string Name" is used like 4 times) I thought of rewriting the XML with a Loop so that the Name variables get renamed into name1, name2, name3 and so on, but I can't figure out how to do that. I use Java as a converter if you can think of any Solutions in Java.
My Output Format is .CSV if that matters.

(any other tips on improving the XSL are appreciated aswell)

Thanks!

答:
It is strange that you have 2 empty string tags.

I suppose, your XML should have the following shape:

```<code><message code="100" description="checkSnr">
  <string name="id">1234</string>
  <string name="serialNr">5678</string>
</message>
</code>```

Then you shoud read both string tags using name attribute with particular value as a predicate:

```<code><xsl:template match="/">
  <xsl:for-each select="machine/events">
    <xsl:text>;</xsl:text>
    <xsl:value-of select="message/@code"/>
    <xsl:text>;</xsl:text>
    <xsl:value-of select="message/string[@name='id']"  />
    <xsl:text>;</xsl:text>
    <xsl:value-of select="message/string[@name='serialNr']"  />
  </xsl:for-each>
</xsl:template>
</code>```

Body:
XML:

<message code="100" description="checkSnr">
  <string name="id"/>
  <string name="serialNr"/>
</message>

XSL:

<xsl:template match="/">
  <xsl:for-each select="machine/events">
    <xsl:text>;</xsl:text>
    <xsl:value-of select="message/@code"/>
    <xsl:text>;</xsl:text>
    <xsl:value-of select="message/string/@name"  />
    <xsl:text>;</xsl:text>
    <xsl:value-of select="message/string/@name"  />
  </xsl:for-each>
</xsl:template>

So here's my Problem. My XSL-File is supposed to detect the value "id" and the value "serialNr", but my Output is "id" x2. I know it is only Logical but how can I actually Change my XSL so it gives me both of the values? (by the way, in the XML there are parts, where the variable "string Name" is used like 4 times) I thought of rewriting the XML with a Loop so that the Name variables get renamed into name1, name2, name3 and so on, but I can't figure out how to do that. I use Java as a converter if you can think of any Solutions in Java.
My Output Format is .CSV if that matters.

(any other tips on improving the XSL are appreciated aswell)

Thanks!

Body:
It is strange that you have 2 empty string tags.

I suppose, your XML should have the following shape:

<message code="100" description="checkSnr">
  <string name="id">1234</string>
  <string name="serialNr">5678</string>
</message>

Then you shoud read both string tags using name attribute with particular value as a predicate:

<xsl:template match="/">
  <xsl:for-each select="machine/events">
    <xsl:text>;</xsl:text>
    <xsl:value-of select="message/@code"/>
    <xsl:text>;</xsl:text>
    <xsl:value-of select="message/string[@name='id']"  />
    <xsl:text>;</xsl:text>
    <xsl:value-of select="message/string[@name='serialNr']"  />
  </xsl:for-each>
</xsl:template>


问:
VAT changes - how to change VAT and then round price up
With the UK VAT rate due to change in the New Year, several clients will need to update their sites to the new VAT rate. As prices are all stored in a MySQL table (excluding VAT), changing the actual VAT rate is a simple flag in the backend of most sites, but this leaves 'ugly' prices £10.87, rather than £10.99.

I'd like to run a query against the prices to alter the prices so that all of the new prices (when the new VAT rate is added) are 'nice' prices rather than ugly ones.

For instance:

Current Price (ex VAT): £8.50

Current Price (VAT @ 17.5%): £9.99

New Price (VAT @ 20%): £10.20

Desired Price (VAT @ 20%): £10.99

答:
if you'd always like prices with .99, it should be pretty easy to do:

```<code>update articles set price = round((ceil(8.50 * 1.2) - 0.01) / 1.2, 2);
</code>```

proof:

```<code>mysql> select round((ceil(8.50 * 1.2) - 0.01) / 1.2, 2) as price;
+-------+
| price |
+-------+
|  9.16 |
+-------+
1 row in set (0.00 sec)
</code>```

in favor of competitive prices you could also consider floor(x) instead of ceil(x) though ;)

Body:
if you'd always like prices with .99, it should be pretty easy to do:

update articles set price = round((ceil(8.50 * 1.2) - 0.01) / 1.2, 2);

proof:

mysql> select round((ceil(8.50 * 1.2) - 0.01) / 1.2, 2) as price;
+-------+
| price |
+-------+
|  9.16 |
+-------+
1 row in set (0.00 sec)

in favor of competitive prices you could also consider floor(x) instead of ceil(x) though ;)

ContentLicense: CC BY-SA 2.5


问:
Facebook Custom Audience Pixel Urls/Domains List
I'm having a hard time in fb docs to find how I can get a list of all the urls/hosts that I placed my custom audience pixels or any other tracking pixels.
https://developers.facebook.com/docs/marketing-api/facebook-pixel/website-custom-audiences/v2.4

I'm able to get the info through the stats endpoint but that seems to be overkill for me to populate a dropdown list in my web application.
https://developers.facebook.com/docs/marketing-api/custom-audience-website-pixel-stats/v2.4

Any suggestion would greatly appreciated.

答:
Go to the Business Manager https://business.facebook.com/ and click
the hamburger menu at the top left.

Click Pixels and then the pixel you want to check

Underneath the graph are some options. Click Domains to see the top level URLs or URLs for a more detailed list

I can't find any way of doing this in code I'm afraid.


问:
My SpringMVC project is not run because of the following errors
Here is the error messages:</p>

```<code>HTTP Status 500 - Servlet.init() for servlet appServlet threw exception

type Exception report

message Servlet.init() for servlet appServlet threw exception

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet.init() for servlet appServlet threw exception
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Thread.java:745)
root cause

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.edu.banking.service.AccountService org.edu.banking.controller.AccountController.accountService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.edu.banking.service.AccountService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
    org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    javax.servlet.GenericServlet.init(GenericServlet.java:158)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Thread.java:745)
root cause

org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.edu.banking.service.AccountService org.edu.banking.controller.AccountController.accountService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.edu.banking.service.AccountService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
    org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
    org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    javax.servlet.GenericServlet.init(GenericServlet.java:158)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Thread.java:745)
root cause

org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.edu.banking.service.AccountService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1373)
    org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1119)
    org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
    org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
    org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
    org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    javax.servlet.GenericServlet.init(GenericServlet.java:158)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Thread.java:745)
note The full stack trace of the root cause is available in the Apache Tomcat/8.5.11 logs
</code>```

答:
```<code>org.springframework.beans.factory.NoSuchBeanDefinitionException:org.edu.banking.service.AccountService
</code>```

This means bean factory could not find the bean defination for AccountService.

```<code>private org.edu.banking.service.AccountService org.edu.banking.controller.AccountController.accountService
</code>```

You have mentioned accountService in your controller and autowired it. something like this

```<code>@Autowired
AccountService  accountService;
</code>```

So please create the AccountService  class or if it is present then add @Service annotation like this

```<code>@Service
class AccountService
</code>```

Also make sure that you have provided the package name AccountService class in component scan .

Body:
Here is the error messages:

HTTP Status 500 - Servlet.init() for servlet appServlet threw exception

type Exception report

message Servlet.init() for servlet appServlet threw exception

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet.init() for servlet appServlet threw exception
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Thread.java:745)
root cause

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.edu.banking.service.AccountService org.edu.banking.controller.AccountController.accountService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.edu.banking.service.AccountService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
    org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    javax.servlet.GenericServlet.init(GenericServlet.java:158)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Thread.java:745)
root cause

org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.edu.banking.service.AccountService org.edu.banking.controller.AccountController.accountService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.edu.banking.service.AccountService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
    org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
    org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    javax.servlet.GenericServlet.init(GenericServlet.java:158)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Thread.java:745)
root cause

org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.edu.banking.service.AccountService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1373)
    org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1119)
    org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
    org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
    org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
    org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    javax.servlet.GenericServlet.init(GenericServlet.java:158)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Thread.java:745)
note The full stack trace of the root cause is available in the Apache Tomcat/8.5.11 logs

Body:
org.springframework.beans.factory.NoSuchBeanDefinitionException:org.edu.banking.service.AccountService

This means bean factory could not find the bean defination for AccountService.

private org.edu.banking.service.AccountService org.edu.banking.controller.AccountController.accountService

You have mentioned accountService in your controller and autowired it. something like this

@Autowired
AccountService  accountService;

So please create the AccountService  class or if it is present then add @Service annotation like this

@Service
class AccountService

Also make sure that you have provided the package name AccountService class in component scan .


问:
I want to get Data from ajax call
I have made this ajax call to get data from view. Now I want to make a new ajax call to get data from this call in a new Ajax call. In short words want to make a new Ajax call on next button which will take data from this Ajax. But I dont know what will its url and how It will get data . Any idea ?</p>

```<code>function loadMaps(id) {
             var field = { id : id };
            var field1 = { id : id };
            jQuery.ajax('{% url "mapport.maps.product" %}', {
                data : field,
                nextpage : field1,

                success: function(response, status, xhr) {
                    showMaps(response.data)
                     pagination(response.nextpage, response.previouspage,                response.currentpage , response.totalpages,response.previousNum, response.nextNum)

                }
            });
        }
</code>```

答:
Or read a little about promises brother, here is an idea you could use

```<code>        var firstTask = new Promise(function (resolve, reject) {

        });
        var secondTask= new Promise(function (resolve, reject) {

        });
        Promise.all([
            firstTask,
            secondTask])
            .then(function(values) {

            // Imagine all your data in one object...

        });
</code>```

etc

Title: I want to get Data from ajax call

Body:
I have made this ajax call to get data from view. Now I want to make a new ajax call to get data from this call in a new Ajax call. In short words want to make a new Ajax call on next button which will take data from this Ajax. But I dont know what will its url and how It will get data . Any idea ?

function loadMaps(id) {
             var field = { id : id };
            var field1 = { id : id };
            jQuery.ajax('{% url "mapport.maps.product" %}', {
                data : field,
                nextpage : field1,

                success: function(response, status, xhr) {
                    showMaps(response.data)
                     pagination(response.nextpage, response.previouspage,                response.currentpage , response.totalpages,response.previousNum, response.nextNum)

                }
            });
        }

Body:
Or read a little about promises brother, here is an idea you could use

        var firstTask = new Promise(function (resolve, reject) {

        });
        var secondTask= new Promise(function (resolve, reject) {

        });
        Promise.all([
            firstTask,
            secondTask])
            .then(function(values) {

            // Imagine all your data in one object...

        });

etc


问:
How to do slice assignment in Tensorflow
I found that Tensorflow provides scatter_update() to assign values to the slice of a tensor in the 0 dimension. For example, if the tensor T is three dimensional, I can assign value v[1, :, :] to T[i, :, :].

```<code>a = tf.Variable(tf.zeros([10,36,36]))
value = np.ones([1,36,36])
d = tf.scatter_update(a,[0],value)

with tf.Session() as sess:
    sess.run(tf.initialize_all_variables())
    print a.eval()
    sess.run(d)
    print a.eval()
</code>```

But how to assign values v[1,1,:] to T[i,j,:]?

```<code>a = tf.Variable(tf.zeros([10,36,36]))
value1 = np.random.randn(1,1,36)
e = tf.scatter_update(a,[0],value1) #Error

with tf.Session() as sess:
    sess.run(tf.initialize_all_variables())
    print a.eval()
    sess.rum(e)
    print a.eval()
</code>```

Is there any other function that TF provide or a simple way to do this?

答:
Currently, you can do slice assignment for variables in TensorFlow. There is no specific named function for it, but you can select a slice and call assign on it:

```<code>my_var = my_var[4:8].assign(tf.zeros(4))
</code>```

First, note that (after having looked at the documentation) it seems that the return value of assign, even when applied to a slice, is always a reference to the whole variable after applying the update.

EDIT: The information below is either deprecated, imprecise or was always wrong. The fact is that the returned value of assign is a tensor that can be readily used and already incorporates the dependency to the assignment, so simply evaluating that or using it in further operations will ensure it gets executed without need for an explicit tf.control_dependencies block.

Note, also, that this will only add the assignment op to the graph, but will not run it unless it is explicitly executed or set as a dependency of some other operation. A good practice is to use it in a tf.control_dependencies context:

```<code>with tf.control_dependencies([my_var[4:8].assign(tf.zeros(4))]):
    my_var = tf.identity(my_var)
</code>```

You can read more about it in TensorFlow issue #4638.

ContentLicense: CC BY-SA 4.0

Body:
I found that Tensorflow provides scatter_update() to assign values to the slice of a tensor in the 0 dimension. For example, if the tensor T is three dimensional, I can assign value v[1, :, :] to T[i, :, :].

a = tf.Variable(tf.zeros([10,36,36]))
value = np.ones([1,36,36])
d = tf.scatter_update(a,[0],value)

with tf.Session() as sess:
    sess.run(tf.initialize_all_variables())
    print a.eval()
    sess.run(d)
    print a.eval()

But how to assign values v[1,1,:] to T[i,j,:]?

a = tf.Variable(tf.zeros([10,36,36]))
value1 = np.random.randn(1,1,36)
e = tf.scatter_update(a,[0],value1) #Error

with tf.Session() as sess:
    sess.run(tf.initialize_all_variables())
    print a.eval()
    sess.rum(e)
    print a.eval()

Is there any other function that TF provide or a simple way to do this?

Body:
Currently, you can do slice assignment for variables in TensorFlow. There is no specific named function for it, but you can select a slice and call assign on it:

my_var = my_var[4:8].assign(tf.zeros(4))

First, note that (after having looked at the documentation) it seems that the return value of assign, even when applied to a slice, is always a reference to the whole variable after applying the update.

EDIT: The information below is either deprecated, imprecise or was always wrong. The fact is that the returned value of assign is a tensor that can be readily used and already incorporates the dependency to the assignment, so simply evaluating that or using it in further operations will ensure it gets executed without need for an explicit tf.control_dependencies block.

Note, also, that this will only add the assignment op to the graph, but will not run it unless it is explicitly executed or set as a dependency of some other operation. A good practice is to use it in a tf.control_dependencies context:

with tf.control_dependencies([my_var[4:8].assign(tf.zeros(4))]):
    my_var = tf.identity(my_var)

You can read more about it in TensorFlow issue #4638.


问:
After drop event i view duplicate event Mysql database
After i have dropped the event in the fullcalendar I see my dropped event and the event rendered from mysql database.

This is my code:

```<code>success: function (json) {
                        $('#calendar').fullCalendar('refetchEvents');
                    }
</code>```

How i can delete or not view the dropped events ?

Thanks

答:
I have resolved in this mode:</p>

```<code>success: function (json) {
           $('#calendar').fullCalendar('removeEvents') //Hide all events
           $('#calendar').fullCalendar('refetchEvents');
           $('#calendar').fullCalendar('gotoDate', start);
                    }
</code>```

Body:
After i have dropped the event in the fullcalendar I see my dropped event and the event rendered from mysql database.

This is my code:

success: function (json) {
                        $('#calendar').fullCalendar('refetchEvents');
                    }

How i can delete or not view the dropped events ?

Thanks

Body:
I have resolved in this mode:

success: function (json) {
           $('#calendar').fullCalendar('removeEvents') //Hide all events
           $('#calendar').fullCalendar('refetchEvents');
           $('#calendar').fullCalendar('gotoDate', start);
                    }


问:
C++ invalid order of execution for cin and cout on XCode
I ran into this issue when I updated both MacOS and XCode.

As you see in the first picture, if I don't put endl into the second cout line "Enter the number" at line 11, this line is put after the cin statement which makes the program run inappropriately.

The cout is printed after accepting input from cin

Here is the output of the program:

However, if I put endl at the end of the line "Enter the number" then the code runs normally.

I already reinstalled XCode the problem is still there. It also affects my old projects which are really annoying.

This is the version of the compiler on my Macbook

```<code>"Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr
--with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1

Apple LLVM version 8.1.0 (clang-802.0.38)

Target: x86_64-apple-darwin16.5.0

Thread model: posix

InstalledDir:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin"
</code>```

I really hope someone can help me solve this issue. I don't know the bug comes from XCode or the GCC.

答: std::cin and std::cout are tied, which means that extraction operations on std::cin first flush std::cout. So your code should work as you expect it to. If it doesn't, then either the standard library that your code uses does not conform to the language definition (unlikely), or there's something funky in your console window (much more likely). Try running the program from the command line.

Body:
I ran into this issue when I updated both MacOS and XCode.

As you see in the first picture, if I don't put endl into the second cout line "Enter the number" at line 11, this line is put after the cin statement which makes the program run inappropriately.

The cout is printed after accepting input from cin

Here is the output of the program:

However, if I put endl at the end of the line "Enter the number" then the code runs normally.

I already reinstalled XCode the problem is still there. It also affects my old projects which are really annoying.

This is the version of the compiler on my Macbook

"Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr
--with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1

Apple LLVM version 8.1.0 (clang-802.0.38)

Target: x86_64-apple-darwin16.5.0

Thread model: posix

InstalledDir:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin"

I really hope someone can help me solve this issue. I don't know the bug comes from XCode or the GCC.


问:
How to get text with formatting from Docs and use it for body to send email
I'd like to send emails from spreadsheet using contents of google docs file for a message (E-mail body). This is what I have now, which works fine.

*Part of code

```<code>var doc = DocumentApp.openById(row[9]);
var message = doc.getText();

MailApp.sendEmail(emailAddress, subject, "Dear " + row[6] +"\n\n"+ message + "\n\n"+ row[1] + "\n" + row[2] + "\n" + row[3] + "\n" + row[4]);
</code>```

It works perfectly fine but the e-mail message is plain text.

I have a little bit of formatting such as Blod/Colored/List format... and etc.
How can I keep those formatting in e-mail message?

I tried getBody() or getParagraph(), but it only returned "Document" or "Paragraph, Paragraph, Paragraph".

*FYI

I tried this. How to send rich text emails with GmailApp?
which worked okay, but I'm trying to find a solution to use rich text directly to email. Not work-around using html format.

答:
```<code>function test_mail_() {
 var id = DocumentApp.getActiveDocument().getId();
 var url = "https://docs.google.com/feeds/download/documents/export/Export?id=" + id + "&exportFormat=html";
 var param = {
    method: "get",
    headers: {
        "Authorization": "Bearer " + ScriptApp.getOAuthToken()
    },
    muteHttpExceptions: true,
 };
 var html = UrlFetchApp.fetch(url, param).getContentText();
 var raw = Utilities.base64EncodeWebSafe("Subject: Test\r\n" +
    "From: " + Session.getActiveUser().getEmail() + "\r\n" +
    "To: test@gmail.com\r\n" +
    "Content-Type: text/html; charset=UTF-8\r\n\r\n" +
    html + "\r\n\r\n");
 var message = Gmail.newMessage();
 message.raw = raw;
 var sentMsg = Gmail.Users.Messages.send(message, 'test@gmail.com');
}
</code>```

This worked for me. hope this may help

Body:
I'd like to send emails from spreadsheet using contents of google docs file for a message (E-mail body). This is what I have now, which works fine.

*Part of code

var doc = DocumentApp.openById(row[9]);
var message = doc.getText();

MailApp.sendEmail(emailAddress, subject, "Dear " + row[6] +"\n\n"+ message + "\n\n"+ row[1] + "\n" + row[2] + "\n" + row[3] + "\n" + row[4]);

It works perfectly fine but the e-mail message is plain text.

I have a little bit of formatting such as Blod/Colored/List format... and etc.
How can I keep those formatting in e-mail message?

I tried getBody() or getParagraph(), but it only returned "Document" or "Paragraph, Paragraph, Paragraph".

*FYI

I tried this. How to send rich text emails with GmailApp?
which worked okay, but I'm trying to find a solution to use rich text directly to email. Not work-around using html format.

Body:
function test_mail_() {
 var id = DocumentApp.getActiveDocument().getId();
 var url = "https://docs.google.com/feeds/download/documents/export/Export?id=" + id + "&exportFormat=html";
 var param = {
    method: "get",
    headers: {
        "Authorization": "Bearer " + ScriptApp.getOAuthToken()
    },
    muteHttpExceptions: true,
 };
 var html = UrlFetchApp.fetch(url, param).getContentText();
 var raw = Utilities.base64EncodeWebSafe("Subject: Test\r\n" +
    "From: " + Session.getActiveUser().getEmail() + "\r\n" +
    "To: test@gmail.com\r\n" +
    "Content-Type: text/html; charset=UTF-8\r\n\r\n" +
    html + "\r\n\r\n");
 var message = Gmail.newMessage();
 message.raw = raw;
 var sentMsg = Gmail.Users.Messages.send(message, 'test@gmail.com');
}

This worked for me. hope this may help


问:
XPath: Select all following nodes until some node
I'm try to parse the structure below into a sets of journey options so that I can find out all the possible ways to get from Pontypridd to Llangollen and back.

Using XPath, I can do //div[@class='JourneyOptions'] to select all the rows that actually contain journey info. Outside of XPath, I could iterate over each row to decide whether it should be added to a set of journeys, or whether it is the first in a new set of journeys.

In the below example, all the journey sets will contain two journeys, but a set may contain just one journey (a 'direct' journey), or more than two (more than one 'connection').

Is there an XPath expression to select all the journeys of the first outbound set, all the journeys of the second outbound set and so on?

The first journey in every set has a radio input with an integer value. I could dynamically generate these to seelct each set, but would need to know when to stop generating (or just wait for the XPath to fail).

```<code><div class='TableHolder'>

  <p>...</p>
  <h2 id='DirectionHeader'>Outbound Options</h2>
  <p>Pontypridd to Llangollen, 30/11/1910</p>

  <!-- first part of the first journey from Pontypridd to Llangollen -->
  <div class='JourneyOptions'>
    <div class='Journey'>
      <div class='ColumnOne'>
          <input type='radio' checked='checked' name='out' value='1'>
      </div>
      ... some more divs of parseable journey info ...
    </div>
  <div>

  <!-- second part of the first journey from Pontypridd to Llangollen -->
  <div class='JourneyOptions'>
    <div class='Journey'>
      <div class='ConnectingJournies'>
          <p>...</p>
      </div>
      <div class='ColumnOne'>
          ... doesn't contain a radio input ...
      </div>
      ... some more divs of parseable journey info ...
    </div>
  </div>

  <!-- first part of the second journey from Pontypridd to Llangollen -->
  <div class='JourneyOptions'>
    <div class='Journey'>
      <div class='ColumnOne'>
          <input type='radio' name='out' value='2'>
      </div>
      ... some more divs of parseable journey info ...
    </div>
  <div>

  <!-- second part of the second journey from Pontypridd to Llangollen -->
  <div class='JourneyOptions'>
    <div class='Journey'>
      <div class='ConnectingJournies'>
          <p>...</p>
      </div>
      <div class='ColumnOne'>
          ... doesn't contain a radio input ...
      </div>
      ... some more divs of parseable journey info ...
    </div>
  </div>

  ... some more outbound journey options ...

  <p>...</p>
  <h2 id='DirectionHeader'>Inbound Options</h2>
  <p>Llangollen to Pontypridd, 07/11/1910</p>

  <!-- first part of the first journey from Llangollen to Pontypridd -->
  <div class='JourneyOptions'>
    <div class='Journey'>
      <div class='ColumnOne'>
          <input type='radio' checked='checked' name='in' value='1'>
      </div>
      ... some more divs of parseable journey info ...
    </div>
  <div>

  <!-- second part of the first journey from Llangollen to Pontypridd -->
  <div class='JourneyOptions'>
    <div class='Journey'>
      <div class='ConnectingJournies'>
          <p>...</p>
      </div>
      <div class='ColumnOne'>
          ... doesn't contain a radio input ...
      </div>
      ... some more divs of parseable journey info ...
    </div>
  </div>

  <!-- first part of the second journey from Llangollen to Pontypridd -->
  <div class='JourneyOptions'>
    <div class='Journey'>
      <div class='ColumnOne'>
          <input type='radio' name='in' value='2'>
      </div>
      ... some more divs of parseable journey info ...
    </div>
  <div>

  <!-- second part of the second journey from Llangollen to Pontypridd -->
  <div class='JourneyOptions'>
    <div class='Journey'>
      <div class='ConnectingJournies'>
          <p>...</p>
      </div>
      <div class='ColumnOne'>
          ... doesn't contain a radio input ...
      </div>
      ... some more divs of parseable journey info ...
    </div>
  </div>

  ... some more inbound journey options ...
</div>
</code>```

Sorry for the large example, but I think this is as small as I can make it while still being representative of my problem.

答:
Node sets are just... well, sets: host language dependency ordered (document order for the most) unique nodes. If you want the result expressing some kind of hierarchy or grouping, the answer is that you can't.

So, you could select the start of each group with:

```<code>/div[@class='TableHolder']
    /div[@class='JourneyOptions']
        [div[@class='Journey']
          /div[@class='ColumnOne']
              /input[@type='radio']
        ]
</code>```

One group at the time (there are many options):

```<code>/div[@class='TableHolder']
    /div[@class='JourneyOptions']
        [count(
            (self::div|preceding-sibling::div)
                [div[@class='Journey']
                    /div[@class='ColumnOne']
                       /input[@type='radio']
                ]
              ) = 1
        ]
</code>```

Body:
I'm try to parse the structure below into a sets of journey options so that I can find out all the possible ways to get from Pontypridd to Llangollen and back.

Using XPath, I can do //div[@class='JourneyOptions'] to select all the rows that actually contain journey info. Outside of XPath, I could iterate over each row to decide whether it should be added to a set of journeys, or whether it is the first in a new set of journeys.

In the below example, all the journey sets will contain two journeys, but a set may contain just one journey (a 'direct' journey), or more than two (more than one 'connection').

Is there an XPath expression to select all the journeys of the first outbound set, all the journeys of the second outbound set and so on?

The first journey in every set has a radio input with an integer value. I could dynamically generate these to seelct each set, but would need to know when to stop generating (or just wait for the XPath to fail).

...

Outbound Options

Pontypridd to Llangollen, 30/11/1910

          <input type='radio' checked='checked' name='out' value='1'>

      ... some more divs of parseable journey info ...

...

          ... doesn't contain a radio input ...

      ... some more divs of parseable journey info ...

          <input type='radio' name='out' value='2'>

      ... some more divs of parseable journey info ...

...

          ... doesn't contain a radio input ...

      ... some more divs of parseable journey info ...

  ... some more outbound journey options ...

...

Inbound Options

Llangollen to Pontypridd, 07/11/1910

          <input type='radio' checked='checked' name='in' value='1'>

      ... some more divs of parseable journey info ...

...

          ... doesn't contain a radio input ...

      ... some more divs of parseable journey info ...

          <input type='radio' name='in' value='2'>

      ... some more divs of parseable journey info ...

...

          ... doesn't contain a radio input ...

      ... some more divs of parseable journey info ...

  ... some more inbound journey options ...

Sorry for the large example, but I think this is as small as I can make it while still being representative of my problem.

Body:
Node sets are just... well, sets: host language dependency ordered (document order for the most) unique nodes. If you want the result expressing some kind of hierarchy or grouping, the answer is that you can't.

So, you could select the start of each group with:

/div[@class='TableHolder']
    /div[@class='JourneyOptions']
        [div[@class='Journey']
          /div[@class='ColumnOne']
              /input[@type='radio']
        ]

One group at the time (there are many options):

/div[@class='TableHolder']
    /div[@class='JourneyOptions']
        [count(
            (self::div|preceding-sibling::div)
                [div[@class='Journey']
                    /div[@class='ColumnOne']
                       /input[@type='radio']
                ]
              ) = 1
        ]


问:
How to convert array of bytes to FileImageSource?
I want to assign an image to button? I have an array of bytes which represents an image. But I don't know how to convert it to the FileImageSource.

答:
What you are trying to do does not seem to be possible. There is no way to achieve this using FileImageSource directly, no matter casting or other options.

For Button.Image you can only use images stored as resources in your platform projects: Resources folder in iOS, Resources/Drawable folder in Android, and application root in WinPhone. These images can be loaded in the button as follows:

```<code>someButton.Image = ImageSource.FromFile("imageName.png");
</code>```

or

```<code>someButton.Image = "imageName.png";
</code>```

Check out the Custom Renderers (see docs). Make sure to also check this thread.

Body:
What you are trying to do does not seem to be possible. There is no way to achieve this using FileImageSource directly, no matter casting or other options.

For Button.Image you can only use images stored as resources in your platform projects: Resources folder in iOS, Resources/Drawable folder in Android, and application root in WinPhone. These images can be loaded in the button as follows:

someButton.Image = ImageSource.FromFile("imageName.png");

or

someButton.Image = "imageName.png";

Check out the Custom Renderers (see docs). Make sure to also check this thread.


问:
App crashes on login, crash when starting dashboard activity
I'm creating a simple login to dashboard app and I'm having trouble with my app launching as I try to launch the dashboard home activity once login is tapped with correct credentials.

```<code>error code: Unable to find explicit activity class {com.example.david.myview3/com.example.david.myview3.DashBoardAppActivity}; have you declared this activity in your AndroidManifest.xml?
</code>```

It is the DashBoardAppActivity.java I wish to launch which happens in the the signIn() method of this class.

```<code>public void signIn(View V)
{
    final Dialog dialog = new Dialog(HomeActivity.this);
    dialog.setContentView(R.layout.login);
    dialog.setTitle("Login");

    // get the Refferences of views
    final  EditText editTextUserName=(EditText)dialog.findViewById(R.id.editTextUserNameToLogin);
    final  EditText editTextPassword=(EditText)dialog.findViewById(R.id.editTextPasswordToLogin);

    Button btnSignIn=(Button)dialog.findViewById(R.id.buttonSignIn);

    // Set On ClickListener
    btnSignIn.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // get The User name and Password
            String userName=editTextUserName.getText().toString();
            String password=editTextPassword.getText().toString();

            // fetch the Password form database for respective user name
            String storedPassword=loginDataBaseAdapter.getSinlgeEntry(userName);

            // check if the Stored password matches with  Password entered by user
            if(password.equals(storedPassword))
            {
                Toast.makeText(HomeActivity.this, "Congrats: Login Successfull", Toast.LENGTH_LONG).show();

                dialog.dismiss();
                startActivity (new Intent(getApplicationContext(), DashBoardAppActivity.class));
            }
            else
            {
                Toast.makeText(HomeActivity.this, "User Name or Password does not match", Toast.LENGTH_LONG).show();
            }
        }
    });
</code>```

DashBoardAppActivity.java

```<code>    import android.app.Activity;
    import android.content.Context;
    import android.content.Intent;
    import android.os.Bundle;
import android.view.View;

public abstract class DashboardAppActivity extends Activity
{
    /** Called when the activity is first created. */
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
    }

    //Lifecycle Methods

    protected void onDestroy()
    {
        super.onDestroy();
    }

    protected void onStop()
    {
        super.onStop();
    }

    protected void onStart()
    {
        super.onStart();
    }

    protected void onPause()
    {
        super.onPause();
    }

    protected void onResume()
    {
        super.onResume();
    }

    //App Click Methods

    public void onSearch(View v)
    {
        startActivity (new Intent(getApplicationContext(), SearchActivity.class));
    }

    public void onAbout(View v)
    {
        startActivity (new Intent(getApplicationContext(), AboutActivity.class));
    }

    public void return2Home(Context context)
    {
        final Intent intent = new Intent(context, HomeActivity.class);
        intent.setFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP);
        context.startActivity (intent);
    }

    public void onPhotoAlbum(View v)
    {
        startActivity (new Intent(getApplicationContext(), PhotoAlbumActivity.class));
    }

    public void onMessage(View v)
    {
        startActivity (new Intent(getApplicationContext(), MessagesActivity.class));
    }

    public void onHome (View v)
    {
        return2Home(this);
    }

}
</code>```

And this is my manifest

```<code>   <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.david.myview3"
    android:versionCode="1"
    android:versionName="1.0">

    <application
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:theme="@style/AppTheme">

        <activity
            android:name=".HomeActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <activity android:name=".DashHomeActivity"
            android:theme="@style/Theme.D1"
            android:label="@string/app_name"
            />

        <activity
        android:name="SignUPActivity"/>

        <activity android:name=".SearchActivity"
            android:theme="@style/Theme.D1"
            android:label="@string/title_search"/>

        <activity android:name=".AboutActivity"
            android:theme="@style/Theme.D1"
            android:label="@string/title_about"
            />
        <activity android:name=".PhotoAlbumActivity"
            android:theme="@style/Theme.D1"
            android:label="@string/title_photoalbum"
            />
        <activity android:name=".MessagesActivity"
            android:theme="@style/Theme.D1"
            android:label="@string/title_message"
            />

</application>

    <uses-sdk android:minSdkVersion="9" />

</manifest>
</code>```

This activity launches fine if I launch one of it's features before it then use said features home feature to return to the dashbaord, it just does not seem to like to go from login to that dashboard first.

答:
DashBoardAppActivity is not defined in android Manifest.xml
It should be something like this</p>

```<code><activity android:name=".DashBoardAppActivity "
            android:theme="@style/Theme.D1"
            android:label="@string/app_name"
            />
</code>```

Body:
I'm creating a simple login to dashboard app and I'm having trouble with my app launching as I try to launch the dashboard home activity once login is tapped with correct credentials.

error code: Unable to find explicit activity class {com.example.david.myview3/com.example.david.myview3.DashBoardAppActivity}; have you declared this activity in your AndroidManifest.xml?

It is the DashBoardAppActivity.java I wish to launch which happens in the the signIn() method of this class.

public void signIn(View V)
{
    final Dialog dialog = new Dialog(HomeActivity.this);
    dialog.setContentView(R.layout.login);
    dialog.setTitle("Login");

    // get the Refferences of views
    final  EditText editTextUserName=(EditText)dialog.findViewById(R.id.editTextUserNameToLogin);
    final  EditText editTextPassword=(EditText)dialog.findViewById(R.id.editTextPasswordToLogin);

    Button btnSignIn=(Button)dialog.findViewById(R.id.buttonSignIn);

    // Set On ClickListener
    btnSignIn.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // get The User name and Password
            String userName=editTextUserName.getText().toString();
            String password=editTextPassword.getText().toString();

            // fetch the Password form database for respective user name
            String storedPassword=loginDataBaseAdapter.getSinlgeEntry(userName);

            // check if the Stored password matches with  Password entered by user
            if(password.equals(storedPassword))
            {
                Toast.makeText(HomeActivity.this, "Congrats: Login Successfull", Toast.LENGTH_LONG).show();

                dialog.dismiss();
                startActivity (new Intent(getApplicationContext(), DashBoardAppActivity.class));
            }
            else
            {
                Toast.makeText(HomeActivity.this, "User Name or Password does not match", Toast.LENGTH_LONG).show();
            }
        }
    });

DashBoardAppActivity.java

    import android.app.Activity;
    import android.content.Context;
    import android.content.Intent;
    import android.os.Bundle;
import android.view.View;

public abstract class DashboardAppActivity extends Activity
{
    /** Called when the activity is first created. */
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
    }

    //Lifecycle Methods

    protected void onDestroy()
    {
        super.onDestroy();
    }

    protected void onStop()
    {
        super.onStop();
    }

    protected void onStart()
    {
        super.onStart();
    }

    protected void onPause()
    {
        super.onPause();
    }

    protected void onResume()
    {
        super.onResume();
    }

    //App Click Methods

    public void onSearch(View v)
    {
        startActivity (new Intent(getApplicationContext(), SearchActivity.class));
    }

    public void onAbout(View v)
    {
        startActivity (new Intent(getApplicationContext(), AboutActivity.class));
    }

    public void return2Home(Context context)
    {
        final Intent intent = new Intent(context, HomeActivity.class);
        intent.setFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP);
        context.startActivity (intent);
    }

    public void onPhotoAlbum(View v)
    {
        startActivity (new Intent(getApplicationContext(), PhotoAlbumActivity.class));
    }

    public void onMessage(View v)
    {
        startActivity (new Intent(getApplicationContext(), MessagesActivity.class));
    }

    public void onHome (View v)
    {
        return2Home(this);
    }

}

And this is my manifest

   <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.david.myview3"
    android:versionCode="1"
    android:versionName="1.0">

    <application
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:theme="@style/AppTheme">

        <activity
            android:name=".HomeActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <activity android:name=".DashHomeActivity"
            android:theme="@style/Theme.D1"
            android:label="@string/app_name"
            />

        <activity
        android:name="SignUPActivity"/>

        <activity android:name=".SearchActivity"
            android:theme="@style/Theme.D1"
            android:label="@string/title_search"/>

        <activity android:name=".AboutActivity"
            android:theme="@style/Theme.D1"
            android:label="@string/title_about"
            />
        <activity android:name=".PhotoAlbumActivity"
            android:theme="@style/Theme.D1"
            android:label="@string/title_photoalbum"
            />
        <activity android:name=".MessagesActivity"
            android:theme="@style/Theme.D1"
            android:label="@string/title_message"
            />

</application>

    <uses-sdk android:minSdkVersion="9" />

</manifest>

This activity launches fine if I launch one of it's features before it then use said features home feature to return to the dashbaord, it just does not seem to like to go from login to that dashboard first.

Body:
DashBoardAppActivity is not defined in android Manifest.xml
It should be something like this

<activity android:name=".DashBoardAppActivity "
            android:theme="@style/Theme.D1"
            android:label="@string/app_name"
            />


问:
iOS alert banner/label?
I apologize if this question is very basic.  I have been googling around but can't seem to find the api/reference for a drop down alert banner/label (I do not know the proper term for this), therefore I am posting here.

This: The label/banner which has "Please enter valid email address" in it.

So here a my questions:

What is the proper term for this (alert banner? notification? label?)

I am trying accomplish similar functionality to what is shown in the image, so basically if any field is invalid, the "label/banner" expands from underneath the navigation bar with the message in it:
If this is just a UILabel, what is the simplest way of adding the expand animation?
If it is something built in, since I have seen bunch of apps do it for alerting, please let me know what its called.

答: For easier control over animating the alert, you can embed your custom view in a UIStackView and simply show/hide it in an animation block. That way will significantly reduce the amount of code needed to animate the visibility of the alert. </p>

Title: iOS alert banner/label?