我有两个xml文件。我在xsl文件中有变量,如下所示,它引用了另一个文件:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:str="http://exslt.org/strings" extension-element-prefixes="str">
<xsl:variable name="testing" select="document('test2.xml')//methods"/>
.....
.....
<xsl:variable name="className" select="@Class" />
<xsl:value-of select="$testing/myClass/@domainName" />
</xsl:stylesheet>
如果我不使用变量并使用直接文本(这是myClass)但是如果我使用变量然后它不起作用,这是有效的。
e.g
<xsl:value-of select="$testing/$className/@domainName" />
- &gt;不工作
或
<xsl:value-of select="$testing/${className}/@domainName" />
- &gt;不工作
或
<xsl:value-of select="concat($testing,'/',$className,'/',@domainName" />
- &gt;不工作
请在这里帮助我,如何在引用变量中使用普通变量?谢谢
答案 0 :(得分:1)
我想你想要locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_COARSE);
criteria.setAltitudeRequired(false);
criteria.setSpeedRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(false);
double lat = 0;
double lng = 0;
provider = locationManager.getBestProvider(criteria, false);
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
Location location = locationManager.getLastKnownLocation(provider);
if (location != null)
{
lat = location.getLatitude();
lng = location.getLongitude();
Toast.makeText(this,"Location"+lat+" "+lng+" ",Toast.LENGTH_LONG).show();
}else
Toast.makeText(this,"Location"+lat+" "+lng+" ",Toast.LENGTH_LONG).show();
。