1 |
<?xml version="1.0" encoding="utf-8"?> |
2 |
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:admin="http://svn.douglasthrift.net/svn/repos/FreeBSDAdmin" exclude-result-prefixes="xsl xs admin"> |
3 |
<xsl:output method="xml" indent="yes"/> |
4 |
|
5 |
<xsl:template match="mpd"> |
6 |
<mpd> |
7 |
<xsl:for-each select="range"> |
8 |
<xsl:variable name="local" as="xs:string" select="local"/> |
9 |
<xsl:variable name="begin" as="xs:integer*" select="admin:ip(begin)"/> |
10 |
<xsl:variable name="end" as="xs:integer*" select="admin:ip(end)"/> |
11 |
<xsl:variable name="width" as="xs:integer" select="width"/> |
12 |
<xsl:variable name="dns" as="xs:string*" select="dns"/> |
13 |
<xsl:for-each select="$begin[1] to $end[1]"> |
14 |
<xsl:variable name="a" as="xs:integer" select="."/> |
15 |
<xsl:for-each select="$begin[2] to $end[2]"> |
16 |
<xsl:variable name="b" as="xs:integer" select="."/> |
17 |
<xsl:for-each select="$begin[3] to $end[3]"> |
18 |
<xsl:variable name="c" as="xs:integer" select="."/> |
19 |
<xsl:for-each select="$begin[4] to $end[4]"> |
20 |
<xsl:call-template name="pptp"> |
21 |
<xsl:with-param name="local" as="xs:string" select="$local"/> |
22 |
<xsl:with-param name="remote" as="xs:string" select="admin:ip($a, $b, $c, .)"/> |
23 |
<xsl:with-param name="width" as="xs:integer" select="$width"/> |
24 |
<xsl:with-param name="dns" as="xs:string*" select="$dns"/> |
25 |
</xsl:call-template> |
26 |
</xsl:for-each> |
27 |
</xsl:for-each> |
28 |
</xsl:for-each> |
29 |
</xsl:for-each> |
30 |
</xsl:for-each> |
31 |
</mpd> |
32 |
</xsl:template> |
33 |
|
34 |
<xsl:function name="admin:ip" as="xs:integer*"> |
35 |
<xsl:param name="ip" as="xs:string"/> |
36 |
<xsl:analyze-string select="$ip" regex="^([0-9]{{1,3}})\.([0-9]{{1,3}})\.([0-9]{{1,3}})\.([0-9]{{1,3}})$"> |
37 |
<xsl:matching-substring> |
38 |
<xsl:value-of select="regex-group(1)"/> |
39 |
<xsl:value-of select="regex-group(2)"/> |
40 |
<xsl:value-of select="regex-group(3)"/> |
41 |
<xsl:value-of select="regex-group(4)"/> |
42 |
</xsl:matching-substring> |
43 |
</xsl:analyze-string> |
44 |
</xsl:function> |
45 |
|
46 |
<xsl:function name="admin:ip" as="xs:string"> |
47 |
<xsl:param name="a" as="xs:integer"/> |
48 |
<xsl:param name="b" as="xs:integer"/> |
49 |
<xsl:param name="c" as="xs:integer"/> |
50 |
<xsl:param name="d" as="xs:integer"/> |
51 |
<xsl:value-of select="concat($a, '.', $b, '.', $c, '.', $d)"/> |
52 |
</xsl:function> |
53 |
|
54 |
<xsl:template name="pptp"> |
55 |
<xsl:param name="local" as="xs:string"/> |
56 |
<xsl:param name="remote" as="xs:string"/> |
57 |
<xsl:param name="width" as="xs:integer"/> |
58 |
<xsl:param name="dns" as="xs:string*"/> |
59 |
<pptp> |
60 |
<local><xsl:value-of select="$local"/></local> |
61 |
<remote width="{$width}"><xsl:value-of select="$remote"/></remote> |
62 |
<xsl:for-each select="$dns"> |
63 |
<dns><xsl:value-of select="."/></dns> |
64 |
</xsl:for-each> |
65 |
</pptp> |
66 |
</xsl:template> |
67 |
</xsl:stylesheet> |