Re: [netmod] XPath node type tests

Phil Shafer <phil@juniper.net> Thu, 26 October 2017 16:27 UTC

Return-Path: <phil@juniper.net>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 85C831384B5 for <netmod@ietfa.amsl.com>; Thu, 26 Oct 2017 09:27:13 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.021
X-Spam-Level:
X-Spam-Status: No, score=-2.021 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=juniper.net
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WFW4pjflAKBn for <netmod@ietfa.amsl.com>; Thu, 26 Oct 2017 09:27:11 -0700 (PDT)
Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0093.outbound.protection.outlook.com [104.47.40.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id AB5E013AD2D for <netmod@ietf.org>; Thu, 26 Oct 2017 09:27:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juniper.net; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=hqwpMGj3XmPVMxYbjrbYiFda+eRoaHW2kEc1IkfZ13U=; b=AlifS0TY2poHHefWDOOroxoX1RXAx+pH7DwNk6BFJVvP/zODEoFQYIHHQTFLE3xD7kB7t6EExwI4dytgNdPuwitKFkM60EG6+WTK2SPHjH9Sb6RObEiBFPDqQC8Oq7UHX2Q3JMG3XQsRnoAN/6xMhc5UECATmU41Vv403Id5AcA=
Received: from SN4PR0501CA0108.namprd05.prod.outlook.com (10.167.128.25) by SN1PR0501MB2080.namprd05.prod.outlook.com (10.163.227.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.178.3; Thu, 26 Oct 2017 16:27:10 +0000
Received: from BY2NAM05FT035.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e52::201) by SN4PR0501CA0108.outlook.office365.com (2603:10b6:803:42::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.197.4 via Frontend Transport; Thu, 26 Oct 2017 16:27:10 +0000
Authentication-Results: spf=softfail (sender IP is 66.129.239.12) smtp.mailfrom=juniper.net; ietf.org; dkim=none (message not signed) header.d=none;ietf.org; dmarc=fail action=none header.from=juniper.net;
Received-SPF: SoftFail (protection.outlook.com: domain of transitioning juniper.net discourages use of 66.129.239.12 as permitted sender)
Received: from p-emfe01a-sac.jnpr.net (66.129.239.12) by BY2NAM05FT035.mail.protection.outlook.com (10.152.100.172) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P256) id 15.20.178.5 via Frontend Transport; Thu, 26 Oct 2017 16:27:10 +0000
Received: from p-mailhub01.juniper.net (10.47.226.20) by p-emfe01a-sac.jnpr.net (172.24.192.21) with Microsoft SMTP Server (TLS) id 14.3.123.3; Thu, 26 Oct 2017 09:27:09 -0700
Received: from idle.juniper.net (idleski.juniper.net [172.25.4.26]) by p-mailhub01.juniper.net (8.14.4/8.11.3) with ESMTP id v9QGR8r5017051; Thu, 26 Oct 2017 09:27:09 -0700 (envelope-from phil@juniper.net)
Received: from idle.juniper.net (localhost [127.0.0.1]) by idle.juniper.net (8.15.2/8.15.2) with ESMTP id v9QGR7fU067102; Thu, 26 Oct 2017 12:27:07 -0400 (EDT) (envelope-from phil@juniper.net)
Message-ID: <201710261627.v9QGR7fU067102@idle.juniper.net>
From: Phil Shafer <phil@juniper.net>
To: Andy Bierman <andy@yumaworks.com>
CC: Robert Wilton <rwilton@cisco.com>, "netmod@ietf.org" <netmod@ietf.org>
In-Reply-To: <CABCOCHROiHZ6ojdamjtto7gbC=WZ_NkaNP6D_pDDeGsGp=X7xQ@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <67100.1509035227.1@idle.juniper.net>
Content-Transfer-Encoding: quoted-printable
Date: Thu, 26 Oct 2017 12:27:07 -0400
X-EOPAttributedMessage: 0
X-MS-Office365-Filtering-HT: Tenant
X-Forefront-Antispam-Report: CIP:66.129.239.12; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(39860400002)(376002)(346002)(2980300002)(199003)(189002)(77096006)(229853002)(4326008)(54906003)(81166006)(46406003)(81156014)(76506005)(69596002)(53416004)(97756001)(8936002)(316002)(6916009)(86362001)(2950100002)(189998001)(7126002)(6246003)(7696004)(106466001)(47776003)(5660300001)(2906002)(97736004)(68736007)(8276002)(356003)(50466002)(105596002)(8746002)(23726003)(53936002)(54356999)(305945005)(478600001)(1076002)(8676002)(2810700001)(50986999)(299355004); DIR:OUT; SFP:1102; SCL:1; SRVR:SN1PR0501MB2080; H:p-emfe01a-sac.jnpr.net; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en;
X-Microsoft-Exchange-Diagnostics: 1; BY2NAM05FT035; 1:mwqlXcSf8P3NaFlptQQjJeelu2gh/C5WW3jayhJPYUdgILV0P4BglPiAj8EYZHS7pccNJB0mOjpc3hu7Lt4GmMJATm4DHJxFQn/dE7ss+lUDp+IH9VlI7eXoyu+pg6Fb
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-Correlation-Id: 2c8b85ec-073a-4c76-b20e-08d51c8e6850
X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627075)(201703031133081)(201702281549075)(2017052603199); SRVR:SN1PR0501MB2080;
X-Microsoft-Exchange-Diagnostics: 1; SN1PR0501MB2080; 3:dRW8jUvoFfW4clD8aI4WWIH0QVj66kYymGNJpJfwqx2vWreum8/Eqf99v1S8d/ziCgBHTDRXBQhChemMgh5TBZiMo27k2Ll5+bcA7N2NFit2IESz7nmzolPr7FByToxOcSdCz1x1jDhN+1t8hUBBasel7dFcqdoRXM8duAqh39t+kXG3DH5juPzO42cx7Uxx+6fKLUx2kwrWcVPCF/nek/B1GouFo3/x4pLd6f1ZsNiwpNh6PmR+AAnXgAqzsBWXK2mGNa+9FTvFFgulwUZG1Is1LMkv3HILBB+vTYEA2iu8dofTr7gMmyITAhH1KPZdpycQRS28nA7yBZa4avpux5yEc8/4sebBFVcQ2P2zV9s=; 25:ypZWM6xiYSWKP669+gP8dH0NhlmhgZ4JSeyWzxg6XmBxyZI4BEXHoEBpsHu+L5RF3j8cNgKZ+YRJVFV9PKWgVd0/TgvIPk7NXXotGEFI37DSwCsAd+w7I46mNzxnTdeC/5TZ4dfGgxq5R7aLFSdQINFe6MVKOrK3Vkip6ObCZmgP+HvLwPLg3gMITKlY1UYb1JIhpiNALa2T9Wd1C0fRrH90hKVR9YvBBo7VSsxy5uaCgglba3bsXVyWYUARBcatNkbDfNtg44tEZZZj4Ji65jtcXQDVaEymBQosyRFwE5udXMZANjy9Z+91SakUz/FVnA/DF1ApBFxWITjwG2ILHg==
X-MS-TrafficTypeDiagnostic: SN1PR0501MB2080:
X-Microsoft-Exchange-Diagnostics: 1; SN1PR0501MB2080; 31:bmw86slkSiyFxp43VfGdK8cxdVa/PHg2coc8uc0s37biUWjPTy4/AwhmECh0Lme1Gy+U9FhdFh/aV0QIvgAzPAc+Hy04RslW9FMBvPc6/yRqPtnFQeLk4XPQ4v2SPxbkoNsE3OFbjYQ114cLBDQJCdGxedXBFuF2ouPxOjMTa8lcnsyu9VOl7+B5AlWbZYmB8rurM3w7U9h7OcIdqod+1Ic1J1ID64j+mGGbUPN8HPE=; 20:t+AZQyOBg69uNDMCLyq6lFgxeu9cFbEBM43nMWl+RL9bKuLyq+POXt+H1mOkTCSBv/bFmi7s/SHE+6kGHFIvw5YRYxFXN0XeiqXHaDbX86bLsST36ipCDDrRMrpdgl7UmD7wsJFhLtkdQaV5m0a5wvglkxG/gofgMR4oYs7OyztZ3TWkkDtmGpkmht2X88u0ZteHXobVXD2Fyt6jnprnrue2iGWc9YMaM7FDyqYKYtjoi1R4TdN3kr2fq6Tg0spWhLKzmauc6jI8N1WzDgMMz97U2k9MZA41YZ5ZuUdScO4uwIcJc5yZIxHHeGF0Kjqk7zuJtJ8roj6VsdCA94dzdeY/GuMDw2Wngadsw3L22benU+QM/V6lVMTk52UWKB3tO2yBLScGSo0mUtG0phoRre+A7B1ugF1n78rt78k8gmiwaOMMzzdlgkl43wjUIjX7sCjVAzqpROP3Y+ovrCObMx9Ddsx0GggUdOqYltSImZa/4nFAtrDfgkXasZID/lou
X-Exchange-Antispam-Report-Test: UriScan:(17755550239193);
X-Microsoft-Antispam-PRVS: <SN1PR0501MB2080168E2CA789D25CA9E7C1C9450@SN1PR0501MB2080.namprd05.prod.outlook.com>
X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(93006095)(93003095)(100000703101)(100105400095)(3231020)(3002001)(10201501046)(6055026)(6041248)(20161123555025)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR0501MB2080; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR0501MB2080;
X-Microsoft-Exchange-Diagnostics: 1; SN1PR0501MB2080; 4:MVJxlie+2FFrUt9upJXIT+McE+NreaJYtZfTJcd9rV6iujns4dnS4AWiocbN/2X4QHv1bRuHxbckXu/1krMqVHWp+EibwslQXk+7jtPbZ39s117a+9EVlX0o3CAzxOgErcflBXv3/3oaj1/3p9eaCWDlWHaougSRmxL3f7eURkhao3in4peRDmX4gFXWYZuMu2h/HwZDp3J6O1ge/6eZhUrD1rDnSAc+gExBSHmb3Qnbi8+BOHoMoDVEYsyhFvxBv9Fpk6HArUt7n4oKdWXlCyN3BH7OKeMuz/OarR+6gjUm1z8uWV6/uKmnj5jSX1fI
X-Forefront-PRVS: 04724A515E
X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR0501MB2080; 23:PzKJqJQKDqanRWNZWekZBWdJQFOzbzOZjloml+g?= =?us-ascii?Q?Tgxygt9f14OIwBy7FlJ/6kmdqEpjw+L4kbsFgywu2QvW4ERBbCtlsZQmKIXC?= =?us-ascii?Q?Byl2thuhNRKOAzsWcPfh93vVEfV2DMSvwiQURO+hYKkGxT+UU0lpZH4lZ8sy?= =?us-ascii?Q?USKvkT1CgLyBchqJ+tj7XmNvwUO0ie4DX9+uFDtgFDZVzI0e28acXM/SFxDs?= =?us-ascii?Q?tbAN+wQ0IC9MxnDxK0WLGiiRsocIJ6M/+45sWMkGd8EqNuDDnuuq7f3nT2Nl?= =?us-ascii?Q?zyEjIzKAAKqkqTYLpAlqZd4ji+N72CEsITR3b29qekUuUsM/TgRanXGCAQqt?= =?us-ascii?Q?DQab/8bwUKdBcR7V53wPtcl6hP2MKyryKWb7jqiefd9b1dMlXpJdIUIwrspS?= =?us-ascii?Q?D9Y6oMzuvABqFRffZqIIKBncu9vO7PzQVwOipMypmIJ1+8BeqyEsZ7Vwg435?= =?us-ascii?Q?p2PGMgOlhdI7rP9M71Th2W7Z04ky2z4dSun47E8R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j1N7kYzqR0+O31J5kGriWVDfh3vYbJHxe7LYAFU7O/drl72Enx93v4ikzJGzK9hk2/A3xbO7eaZPD8ANPEZ59zIF4It86J4QWKv1tNpaO4eL9s2zswD1/jK1FxVw/kqWx1uM=; 5:51DBa7lMAwMAV+68Vo0SCf4YJsgZUcG4FI3uV0d6uMkPBKgVVBqV4sn5E9nt5jY/lXWyCKjdZSLI634pUHiguNKa1Rk8bNMcmKS1sgzRI5eaLf6JCe0HiaERrWeq5KvC9YZF4vu2fWyVfz64ghTb29+nvHhWfXqFAjfAwCYKa8Q=; 24:c5l4qN3rH7uDGGGzNNYJlqhNTRC32B+BdQyqQDF73sIUsmyW++25SitoN9xLaJeGRTHjC9M7u9yt1RgbBNubfHhsAeV/v+3CLODntSMf+SM=; 7:byDIQSpjEuSI50+xUERiCSzRCriHL4owYsHi2zfJMn9N4a4n2Mohs7hBwesNILBg2fFQDKuU8xw9L4ljjYn1p8vQosvruKaltto0bJ/DWQSU9X7I+N5+B0Cj4NjMAk0ThiQ9S7x2PrlVtHxnFYcIUIVu1wS3v6KLPa7WV0wyDy2qNX+90Ux+pntNSnTo8BhgCTiV6gPCTryixKJU5ydC4nAkbulOhJxjXYv5EaqpzgPG3UI2YWjywf+AgiEwIooJ
SpamDiagnosticOutput: 1:99
SpamDiagnosticMetadata: NSPM
X-OriginatorOrg: juniper.net
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2017 16:27:10.1658 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: 2c8b85ec-073a-4c76-b20e-08d51c8e6850
X-MS-Exchange-CrossTenant-Id: bea78b3c-4cdb-4130-854a-1d193232e5f4
X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=bea78b3c-4cdb-4130-854a-1d193232e5f4; Ip=[66.129.239.12]; Helo=[p-emfe01a-sac.jnpr.net]
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR0501MB2080
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/lEgzb8JwzL1OmQKWdHXJ4rgjgf0>
Subject: Re: [netmod] XPath node type tests
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 26 Oct 2017 16:27:13 -0000

Andy Bierman writes:
>I think text() and node() are just filter tests.
>
>  /foo/*[text()] would return all the child nodes of /foo that are leaf or
>leaf-list
>
>text() returns a boolean (0 or 1).  Do not use it for value testing:
>
>  /foo/*[text() =3D 'fred']  // wrong!
>
>  /foo/*[. =3D 'fred']  // correct

I haven't looked at the spec, but this isn't true for libxml2/libxslt/libslax:

(sdb) n
4: var $foo := <top> { <one> "one"; <two> "two"; }
(sdb) n
2: main <foo> { }
(sdb) p $foo
[node-set] (1) rtf-doc
<top>
  <one>one</one>
  <two>two</two>
</top>


(sdb) p $foo/*
[node-set] (1)
<top>
  <one>one</one>
  <two>two</two>
</top>

Outside predicates, it's a node test, matching text nodes:

(sdb) p $foo/*/text()
[node-set] (0)

(sdb) p $foo/*/*/text()
[node-set] (2)
one
two

But inside predicates is does return the text, probably like string():

(sdb) p $foo/*/*
[node-set] (2)
<one>one</one>
<two>two</two>

(sdb) p $foo/*[text() == 'one']
[node-set] (0)

(sdb) p $foo/*/*[text() == 'one']
[node-set] (1)
<one>one</one>

It could be just a bug in libxml2;  I'll take a look.

Thanks,
 Phil

P.s.: the command line I used was:

   slaxproc -d -m 'main <foo> { }' -E -m 'var $foo := <top> { <one> "one"; <two> "two"; }'

The ":=" operator turns RTFs into node-sets (via calling node-set()).