Tuesday, 3 September 2013

Which namespace is used for xsl:element when name is an attribute value template

Which namespace is used for xsl:element when name is an attribute value
template

I'm trying to understand how xsl:element works properly and I have this
test transform:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="test">
<test1/>
<xsl:element name="test2"/>
<xsl:variable name="three" select="3"/>
<xsl:element name="test{$three}"/>
</xsl:template>
</xsl:stylesheet>
When applied to this document:
<?xml version="1.0" encoding="UTF-8"?>
<test/>
I get this result using xsltproc
<?xml version="1.0"?>
<test1 xmlns="http://www.w3.org/1999/xhtml"/>
<test2 xmlns="http://www.w3.org/1999/xhtml"/>
<test3/>
Why is the test3 node not in the same namespace as test1 and test2?

PHP CURL SAME HTML ELEMENT

PHP CURL SAME HTML ELEMENT

i want to output the third element from the same html element , i know how
to output a div/span with a id or a class but i have no idea how to output
a same html element, i tought it was something with p[1] but it doesnt
work , i know there is a lot of answered questions about it but it never
explained how to output the same html element without a class/id
website : http://localhost/
<p>example</p>
<p>example1</p> <!-- i want to take this one -->
<p>example2</p>
-------------------
php script :
<?php $curl = curl_init('http://localhost/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$code3 = curl_exec($curl);
curl_close($curl);
$code = '/<h1>(.*?)<\/h1>/s';
$code6= preg_match($code, $code3, $code4);
echo $code4[1]
?>
/* doesnt work ..
also php.net doesnt give a good example about it so i hope someone can
help me here.
thanks advanced !
*/

For Loop checking player locations

For Loop checking player locations

This is a Bukkit plugin, for Minecraft, using their API.
I'm trying to check if a player is in a specified location, and if they
are, then don't teleport a player there. Instead, check another location,
and spawn the player there if it's empty.
It may be better explained by the code below:
Player player = (Player) sender;
List<Player> prisoners = new ArrayList<Player>();
for (int i = 0; i < prisoners.size(); i++) {
//loc(1-12) are coords in the form of a location variable. I just wanted
to save some room.
if (!(loc1 == prisoners.get(i))){
player.teleport(loc1);
}else if (!(loc1 == prisoners.get(i).getLocation())){
player.teleport(loc2);
}else if (!(loc2 == prisoners.get(i).getLocation())){
player.teleport(loc3);
}else if (!(loc3 == prisoners.get(i).getLocation())){
player.teleport(loc4);
}else if (!(loc4 == prisoners.get(i).getLocation())){
player.teleport(loc5);
}else if (!(loc5 == prisoners.get(i).getLocation())){
player.teleport(loc6);
}else if (!(loc6 == prisoners.get(i).getLocation())){
player.teleport(loc7);
}else if (!(loc7 == prisoners.get(i).getLocation())){
player.teleport(loc8);
}else if (!(loc8 == prisoners.get(i).getLocation())){
player.teleport(loc9);
}else if (!(loc9 == prisoners.get(i).getLocation())){
player.teleport(loc10);
}else if (!(loc10 == prisoners.get(i).getLocation())){
player.teleport(loc11);
}else if (!(loc11 == prisoners.get(i).getLocation())){
player.teleport(loc12);
}else {
player.sendMessage("Sorry, the Prisoner's team is full. Try joining the
Guards, or wait until the next round.");
player.teleport(lobby);
prisoners.remove(player);
}
I want to check each location, and teleport the player to the next
available location by going through the list of players on the prisoner's
team, and checking their location.
Thanks in advance!

Lyrics in the Gracenote

Lyrics in the Gracenote

How can I get lyric information on a track? I notice all other information
is available and I have been reading that gracenote offers lyric database
lookup. If this is possible can someone get me on the right path on how to
get started or the documentation for this?
I'm using GNSDK.
Thanks,
Renan

exact cost of database round trip vs. wcf service invocation

exact cost of database round trip vs. wcf service invocation

I've been googling for exact figures on how expensive round trips are, but
could not find any. Are there any concrete numbers given anywhere?
So, we are developing an enterprise solution. We plan to have a thin
client connected to a wcf service. In the service we plan to have an ORM
(most likely NH) with a 2nd level cache.
Obviously there are numerous benefits to having a service, prominently to
encapsulate all the business rules, enable multiple clients to manage
concurrency, etc. But! Performance-wise how does invoking the service from
the thin client compare to simply executing raw sql on the client? The
service is an added over-head and will surely be slower if the service's
orm cache is not hit. Is there some article discussing this in some depth?

Filtering Combobox choices

Filtering Combobox choices

I have a data grid containing
Client Name Account Type Date Created
I also have 3 comboboxes which when an item is clicked it calls the
SelectedIndexChanged
function which is then reflected in the data grid by moving to a matching
occurance . However multiple clients can have the same account type so I
want my combobox to work so that if an account type is clicked it calls
the selectedIndexChanged function such that it moves to a row where the
account type is correct but the Client name is also contained in that row

Monday, 2 September 2013

Printing alternate even and prime numbers?

Printing alternate even and prime numbers?

The required output of this program was to print alternate even and prime
numbers till 'n' terms.But the problem is, even though there is no error
reported, I'm unable to get the desired result. Can anyone please point
out the bug, or give me another coding for this to work.
required output:"2,2,4,3,6,5,8,7...n terms".
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{clrscr();
int k=0,c=2,g=0,n=10,f=0; //'c'-prime number counter,'k'-even no
counter,'n'-number of terms
do
{ k+=2;cout<<k;g++; //for printing even numbers(k). 'g'is the counter
for(int i=0;i<1000;i++) //F-1. run this loop large numbr of times
{ f=0;
for(int j=0;j<c/2;j++) //F-2
{
if((c%j)==0) { f++;} //checking prime
}//end of loop F-2
if(f==0){cout<<c;c++;break;}//to come out of loop F-1 as 'c' is a prime
number.
else {c++; } //checking for next prime number
}//end of loop F-1
} while(g<n);
getch();
}