From owner-freebsd-arch@FreeBSD.ORG Thu Jul 31 18:17:03 2014 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A1DC34B2; Thu, 31 Jul 2014 18:17:03 +0000 (UTC) Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2lp0204.outbound.protection.outlook.com [207.46.163.204]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mail.protection.outlook.com", Issuer "MSIT Machine Auth CA 2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2F69424D2; Thu, 31 Jul 2014 18:17:02 +0000 (UTC) Received: from BY2PR05CA044.namprd05.prod.outlook.com (10.141.250.34) by BLUPR05MB723.namprd05.prod.outlook.com (10.141.207.153) with Microsoft SMTP Server (TLS) id 15.0.995.14; Thu, 31 Jul 2014 18:16:59 +0000 Received: from BN1BFFO11FD049.protection.gbl (2a01:111:f400:7c10::1:167) by BY2PR05CA044.outlook.office365.com (2a01:111:e400:2c5f::34) with Microsoft SMTP Server (TLS) id 15.0.995.14 via Frontend Transport; Thu, 31 Jul 2014 18:16:58 +0000 Received: from P-EMF02-SAC.jnpr.net (66.129.239.16) by BN1BFFO11FD049.mail.protection.outlook.com (10.58.145.4) with Microsoft SMTP Server (TLS) id 15.0.990.10 via Frontend Transport; Thu, 31 Jul 2014 18:16:58 +0000 Received: from magenta.juniper.net (172.17.27.123) by P-EMF02-SAC.jnpr.net (172.24.192.21) with Microsoft SMTP Server (TLS) id 14.3.146.0; Thu, 31 Jul 2014 11:16:57 -0700 Received: from idle.juniper.net (idleski.juniper.net [172.25.4.26]) by magenta.juniper.net (8.11.3/8.11.3) with ESMTP id s6VIGmn45624; Thu, 31 Jul 2014 11:16:48 -0700 (PDT) (envelope-from phil@juniper.net) Received: from idle.juniper.net (localhost [127.0.0.1]) by idle.juniper.net (8.14.4/8.14.3) with ESMTP id s6VIGR07096191; Thu, 31 Jul 2014 14:16:31 -0400 (EDT) (envelope-from phil@idle.juniper.net) Message-ID: <201407311816.s6VIGR07096191@idle.juniper.net> To: Garance A Drosehn Subject: Re: XML Output: libxo - provide single API to output TXT, XML, JSON and HTML In-Reply-To: <08B4AE10-1747-4BB1-AA1A-BA4491A57F95@rpi.edu> Date: Thu, 31 Jul 2014 14:16:27 -0400 From: Phil Shafer MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:66.129.239.16; CTRY:US; IPV:NLI; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(6009001)(164054003)(199002)(189002)(69596002)(105596002)(103666002)(46102001)(31966008)(21056001)(74662001)(74502001)(77982001)(79102001)(76482001)(84676001)(110136001)(6806004)(68736004)(44976005)(85306003)(95666004)(47776003)(102836001)(106466001)(48376002)(53416004)(86362001)(92726001)(97736001)(85852003)(64706001)(83322001)(99396002)(81342001)(81542001)(83072002)(50986999)(76506005)(92566001)(4396001)(50466002)(54356999)(87936001)(107046002)(81156004)(80022001)(2171001)(20776003); DIR:OUT; SFP:; SCL:1; SRVR:BLUPR05MB723; H:P-EMF02-SAC.jnpr.net; FPR:; MLV:sfv; PTR:InfoDomainNonexistent; MX:1; LANG:en; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID: X-Forefront-PRVS: 0289B6431E Received-SPF: SoftFail (protection.outlook.com: domain of transitioning juniper.net discourages use of 66.129.239.16 as permitted sender) Authentication-Results: spf=softfail (sender IP is 66.129.239.16) smtp.mailfrom=phil@juniper.net; X-OriginatorOrg: juniper.net Cc: arch@freebsd.org, marcel@freebsd.org, "Simon J. Gerraty" X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Jul 2014 18:17:03 -0000 Garance A Drosehn writes: >What if there's something you want to print out for xml/json but >*not* for plain-text? (it's easy to imagine some commands might >print out more values when they are not constrained by an 80-char >width). The "d" flag instructs libxo so only emit for "display" formats (TEXT, HTML) and the "e" flag for "encode" formats (XML, JSON). xo_emit("{d:count}{e:count}", "fourth", "4"); >Also, given that machine-readable outputs might change over time, >is there the idea of including a version-number with the output >for each command? I imagine at some point in the future we could see YANG models for this output, with revision strings and more. In practice, this turns out to be a minor issue, if strong discipline is maintained. Future versions can emit new tags, but not remove old tags. So a script that uses an XPath expression like: user-entry[user == 'phil' && idle/@seconds > 6000] it should work forever. XML becomes an API, where your API makes a contract saying "I won't change" and deprecating XML elements becomes as rare as deprecating functions in libc. >I hope it doesn't seem like I'm just complaining about the work >everyone else is doing (both this and the GSOC project). Please >note that I've attempted to do this a few times myself, and I haven't >been happy with any of *my* attempts either! I'm been kicking this idea around in my head for years. The first XML API in JUNOS was 2001. But the way we do this in JUNOS is not a good fit for BSD; we emit XML from our daemons and the CLI uses an output definition language to know how to turn XML into text. BSD needs point-of-creation content generation flexibility, and some scheme for the shell/parent to tell the what sort of data should be generated. I'm using the LIBXO_OPTIONS variable to do this, so your RESTful API daemon can set this env var, run the command, and funnel the output back to the client. There needs to be a mechanism for marking the executable to say which types of data formats are support, or if libxo is supported at all. Thanks, Phil