Thursday 26 March 2015

XSLT group by postion

Issue

Need to create individual files each with n nodes from the master file

Resolution

There is a simple resolution to this although it is specific to XSLT 2. This uses the for-each-group routine and the idiv operator. idiv is an integer division which is equivalent to (x div y) cast as xs:integer

Consider a nodeset held as a variable $nodes and a group size of nodes defined by the integer variable $groupsize, then using the following routine will split the nodeset into distinct files with $groupsize nodes to each file

XSLT

<xsl:for-each-group select="$nodes" 
    group-adjacent="(position() - 1) idiv $groupsize">
 
    <xsl:result-document href="{concat('resultdoc', format-number(position(),'000'), '.xml')}">
        <result>
            <xsl:sequence select="current-group()"/>
        </result>
    </xsl:result-document>
</xsl:for-each-group>

Thursday 12 March 2015

netstat switches

The following switches can be used with the ipconfig command line utility:

SwitchEffect
-a Displays all connections and listening ports
-bDisplays the executable involved in creating each connection or listening port
-eDisplays Ethernet statistics
-fDDisplays Fully Qualified Domain Names for foreign addresses. (In Windows Vista/7 only)
-nDisplays addresses and port numbers in numerical form
-o Displays the owning process ID associated with each connection
-p protocol Shows connections for the protocol specified by proto; proto may be any of: TCP, UDP, TCPv6, or UDPv6.
-rDisplays the routing table
-s Displays per-protocol statistics
-tDDisplays the current connection offload state, (Windows Vista/7)
-v When used in conjunction with -b, will display sequence of components involved in creating the connection or listening port for all executables. (Windows XP SP2, SP3)
[interval] An integer used to display results multiple times with specified number of seconds between displays. Continues until stopped by command ctrl+c. Default setting is to display once

Common usage netsta -a -n -o

Use the pid to cross reference with the process running in Task Manager

Xquery: for $x at $position in $seq expression

A useful expression available to xquery is the "for x at $position in $seq expression" (for at in expression)


for $x at $position in $seq
 return
  if ($position = 1) then
   (: do something :)
  else if ($position = 2) then
   (: do something else :)
  else
   (: default :)