一区二区三区日韩精品-日韩经典一区二区三区-五月激情综合丁香婷婷-欧美精品中文字幕专区

分享

Jan

 sven_ 2014-05-22

When last discussing using the XML produced by BIND's statistics server, I showed you how I created a C program to parse the XML, but it didn't occur to me to use XSL and the xsltproc utility to do so.

BIND9 old XML format

A kind reader added a comment to that post a few moments ago, and I took the liberty of streamlining his code a bit to produce this:

<xsl:stylesheet version="1.0" xmlns="http://www./1999/xhtml" xmlns:xsl="http://www./1999/XSL/Transform">
<!--
  ** XSLT to parse BIND9 XML from the statistics-server (old format)
  ** inspired by a comment by Andrii Shynkarchuk on 
  ** http:///2010/10/21/using-binds-statistics-server-to-list-zones-and-axfr-the-list/
  **
  ** Set the view name you're interested in where it says "_default"
  ** (This could be accessed with an XSLT param or so.)
  -->
<xsl:output method="text" />
  <xsl:strip-space elements="*"/>

  <xsl:template match="isc/bind/statistics">
    <xsl:apply-templates select="views/view">
    </xsl:apply-templates></xsl:template>
      <xsl:template match="views/view">
      <xsl:choose>
    <xsl:when test="name='_default'">
        <xsl:for-each select="zones/zone">
            <xsl:value-of select="serial" />
            <xsl:text> </xsl:text> 
            <!-- zone name only (w/o class/view) -->
            <xsl:value-of select="substring-before(name, '/')" />
            <xsl:text>&#xa;</xsl:text> <!-- newline -->
        </xsl:for-each>

    </xsl:when>
      </xsl:choose>
    </xsl:template>
</xsl:stylesheet>

If I run the result through xsltproc on a 240MB XML file containing 136,000 zones, I get results in 8 seconds on my laptop, which is pretty good.

curl -qs http://172.16.153.101:8053/ |
    xsltproc bconvert.xsl -
2012011108 example.com
0 0.in-addr.arpa
0 1.0.0.127.in-addr.arpa
0 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa
2011080707 example.org
97 big.aa
...

BIND9 newstats XML format

And this works for me for the "newstats" format, introduced experimentally in 9.9.3:

<xsl:stylesheet version="1.0" xmlns="http://www./1999/xhtml" xmlns:xsl="http://www./1999/XSL/Transform">
<!--
  ** XSLT to parse BIND9 (version3) XML from the statistics-server (new format)
  ** inspired by a comment by Andrii Shynkarchuk on 
  ** http:///2010/10/21/using-binds-statistics-server-to-list-zones-and-axfr-the-list/
  **
  ** Set the view name you're interested in where it says "_default"
  ** (This could be accessed with an XSLT param or so.)
  -->
<xsl:output method="text" />
  <xsl:strip-space elements="*"/>

<xsl:template match="statistics"> 
    <xsl:apply-templates select="views/view">
    </xsl:apply-templates></xsl:template>
      <xsl:template match="views/view">
        <xsl:for-each select="zones/zone">
            <xsl:value-of select="serial" />
            <xsl:text> </xsl:text> 
            <xsl:value-of select="@name" />
            <xsl:text>&#xa;</xsl:text> <!-- newline -->
        </xsl:for-each>
</xsl:template> 
</xsl:stylesheet>

Thank you, Andrii. :)

BIND, XML, and XSL :: 01 Mar 2013 :: e-mail

Comments

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類(lèi)似文章 更多

    亚洲国产色婷婷久久精品| 欧美日韩一区二区三区色拉拉| 亚洲熟女诱惑一区二区| 欧美整片精品日韩综合| 男女午夜视频在线观看免费| 亚洲第一区二区三区女厕偷拍| 中文字幕av诱惑一区二区| 亚洲天堂精品在线视频| 色偷偷亚洲女人天堂观看| 亚洲精品有码中文字幕在线观看| 成人欧美一区二区三区视频| 99秋霞在线观看视频| 精品偷拍一区二区三区| 久久中文字人妻熟女小妇| 91插插插外国一区二区| 麻豆剧果冻传媒一二三区| 国产精品香蕉免费手机视频| 老鸭窝老鸭窝一区二区| 国产精品一区二区三区欧美| 国产欧美日韩一级小黄片| 日韩精品视频免费观看| 东京热男人的天堂久久综合| 人妻巨大乳一二三区麻豆| 亚洲欧美日韩精品永久| 亚洲淫片一区二区三区| 国产精品免费无遮挡不卡视频 | 欧美不卡一区二区在线视频| 亚洲内射人妻一区二区| 欧美一二三区高清不卡| 日本熟女中文字幕一区| 国产丝袜极品黑色高跟鞋| 亚洲中文字幕乱码亚洲| 午夜精品一区二区三区国产| 欧美一级不卡视频在线观看| 能在线看的视频你懂的| 成年午夜在线免费视频| 这里只有九九热精品视频| 日本加勒比在线观看不卡| 国产成人综合亚洲欧美日韩| 欧美午夜色视频国产精品| 日韩少妇人妻中文字幕|