Wednesday, May 23, 2012

filtering non referenced member nodes using XSLT

An OpenStreetMap xml document is composed (among other things) of a set of "node" elements and a set of "way" elements.



The "node" elements can (optionally) nest "tag" elements.



The "way" elements are composed by an ordered list of "node" elements, referenced by the nested elements "nd", with their attribute "ref" pointing to the attribute "id" at the "node" elements.



Here an example:



<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="CGImap 0.0.2">
<node id="1726631203" lat="50.8500083" lon="4.3553223" visible="true" version="6" changeset="9938190" timestamp="2011-11-24T22:05:32Z"/>
...
<way id="160611697" user="toSc" uid="246723" visible="true" version="1" changeset="11385198" timestamp="2012-04-22T14:57:19Z">
<nd ref="1726631203"/>
<nd ref="1726631223"/>
<nd ref="1726631213"/>
<nd ref="1726631205"/>
<nd ref="1726631185"/>
<nd ref="1726631203"/>
</way>
...
</osm>


My question is how, using XSLT, could I do the following transformation ?




  • Filtering all the node elements that are not referenced by any way element.

  • Filtering the way elements that reference node elements not included in the source xml document.

  • Changing the attribute "visible" to "false", to any "node" element not having "tag" children elements.



Any other elements should remain in the generated xml.





SQL Compact Edition (CE) and password complexity requirements

In Windows 7 we have group policies enforcing password complexity requirements which demands "better" password for SQL server express.



Does this impact SQL CE as well?





PHPass implementation in java

I want to use PHPass encryption technique in java. Is there any way we can achieve it?





How to sum two lists element-wise

I want to parse a file line by line, each of which containing two integers, then sum these values in two distinct variables. My naive approach was like this:



my $i = 0;
my $j = 0;
foreach my $line (<INFILE>)
{
($i, $j) += ($line =~ /(\d+)\t(\d+)/);
}


But it yields the following warning:




Useless use of private variable in void context




hinting that resorting to the += operator triggers evaluation of the left-hand side in scalar instead of list context (please correct me if I'm wrong on this point).



Is it possible to achieve this elegantly (possibly in one line) without resorting to arrays or intermediate variables?






Related question: How can I sum arrays element-wise in Perl?





Non capturing group issue

Why following return ["vddv"] instead of ["dd"]:



"aaavddv".match(/(?:v).*(?:v)/)




jquery rounded corners on first and last li

How do i create rounded top left and bottom left corners of the first LI and rounded top right and bottom right of the last li using jquery?



I understand that i could use border-radius but that wont be a cross browser solution.



Here is what i have started: http://jsfiddle.net/c7NyZ/1/



If you can add a resource to the jsfiddle and update it id be greatful.



HTML:



<div id="new-menu-upper">
<ul id="top-nav">
<li><a href="/t-topnavlink.aspx">menu item 1</a></li>
<li><a href="/t-topnavlink.aspx">menu item 2</a></li>
<li><a href="/t-topnavlink.aspx">menu item 3</a></li>
<li><a href="/t-topnavlink.aspx">menu item 4</a></li>
<li><a href="/t-topnavlink.aspx">menu item 5</a></li>
<li><a href="/t-topnavlink.aspx">menu item 6</a></li>
</ul>
</div>


CSS:



div#new-menu-upper {
border: 0 solid red;
height: 40px;
margin: 0 5px 10px;
padding-top: 63px;
}
ul#top-nav li {
background-image: url("http://i47.tinypic.com/21nqxjc.png");
background-repeat: repeat;
border-right: 2px solid lightgrey;
float: left;
height: 41px;
width: 156px;
}
ul#top-nav li a {
color: White;
display: inline-block;
font-family: Arial;
font-size: 12px;
font-weight: bold;
letter-spacing: 1px;
padding-left: 38px;
padding-top: 12px;
text-transform: uppercase;
}


EDIT: IT HAS TO BE A CROSS BROWSER SOLUTION, MEANING IT HAS TO WORK WITH MIN IE7
*EDIT: ADDED JQUERY.CORNERS RESOURCE TO JSFIDDLE AND TRIED TO MAKE FIRST LI RENDER WITH CORNER BUT ITS NOT WORKING - PLEASE CAN YOU HELP - http://jsfiddle.net/c7NyZ/4/ *





Using "libs" and "lib" directories?

I use the directory "libs" for a native libs, and "lib" for jars. Ant compilation works fine, if to override the property "jar.libs.dir=lib" in local.properties file. looks good. But a jars from "lib" directory was not included into APK file.



You can see base build.xml (android_sdk/tools/ant/build.xml)



            <classpath>
<fileset dir="${extensible.libs.classpath}" includes="*.jar" />
</classpath>


where extensible.libs.classpath - is jar.libs.dir.



How to fix it? I can't to use only one "libs" dir.



I saw the log file (classes.dex.d), my jars are not included. but if I use "jar.libs.dir=lib" AND move the jars into "libs" - works fine! I don't understand this regularity