PATH:
usr
/
share
/
augeas
/
lenses
/
dist
(* XML lens for Augeas Author: Francis Giraldeau <francis.giraldeau@usherbrooke.ca> Reference: http://www.w3.org/TR/2006/REC-xml11-20060816/ *) module Xml = autoload xfm (************************************************************************ * Utilities lens *************************************************************************) let dels (s:string) = del s s let spc = /[ \t\r\n]+/ let osp = /[ \t\r\n]*/ let sep_spc = del /[ \t\r\n]+/ " " let sep_osp = del /[ \t\r\n]*/ "" let sep_eq = del /[ \t\r\n]*=[ \t\r\n]*/ "=" let nmtoken = /[a-zA-Z:_][a-zA-Z0-9:_.-]*/ let word = /[a-zA-Z][a-zA-Z0-9._-]*/ let char = /.|(\r?\n)/ (* if we hide the quotes, then we can only accept single or double quotes *) (* otherwise a put ambiguity is raised *) let sto_dquote = dels "\"" . store /[^"]*/ . dels "\"" (* " *) let sto_squote = dels "'" . store /[^']*/ . dels "'" let comment = [ label "#comment" . dels "<!--" . store /([^-]|-[^-])*/ . dels "-->" ] let pi_target = nmtoken - /[Xx][Mm][Ll]/ let empty = Util.empty let del_end = del />[\r?\n]?/ ">\n" let del_end_simple = dels ">" (* This is siplified version of processing instruction * pi has to not start or end with a white space and the string * must not contain "?>". We restrict too much by not allowing any * "?" nor ">" in PI *) let pi = /[^ \r\n\t]|[^ \r\n\t][^?>]*[^ \r\n\t]/ (************************************************************************ * Attributes *************************************************************************) let decl = [ label "#decl" . sep_spc . store /[^> \t\n\r]|[^> \t\n\r][^>\t\n\r]*[^> \t\n\r]/ ] let decl_def (r:regexp) (b:lens) = [ dels "<" . key r . sep_spc . store nmtoken . b . sep_osp . del_end_simple ] let elem_def = decl_def /!ELEMENT/ decl let enum = "(" . osp . nmtoken . ( osp . "|" . osp . nmtoken )* . osp . ")" let att_type = /CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/ | enum let id_def = [ sep_spc . key /PUBLIC/ . [ label "#literal" . sep_spc . sto_dquote ]* ] | [ sep_spc . key /SYSTEM/ . sep_spc . sto_dquote ] let notation_def = decl_def /!NOTATION/ id_def let att_def = counter "att_id" . [ sep_spc . seq "att_id" . [ label "#name" . store word . sep_spc ] . [ label "#type" . store att_type . sep_spc ] . ([ key /#REQUIRED|#IMPLIED/ ] | [ label "#FIXED" . del /#FIXED[ \r\n\t]*|/ "" . sto_dquote ]) ]* let att_list_def = decl_def /!ATTLIST/ att_def let entity_def = decl_def /!ENTITY/ ([sep_spc . label "#decl" . sto_dquote ]) let decl_def_item = elem_def | entity_def | att_list_def | notation_def let decl_outer = sep_osp . del /\[[ \n\t\r]*/ "[\n" . (decl_def_item . sep_osp )* . dels "]" (* let dtd_def = [ sep_spc . key "SYSTEM" . sep_spc . sto_dquote ] *) let doctype = decl_def /!DOCTYPE/ (decl_outer|id_def) (* General shape of an attribute * q is the regexp matching the quote character for the value * qd is the default quote character * brx is what the actual attribute value must match *) let attval (q:regexp) (qd:string) (brx:regexp) = let quote = del q qd in let body = store brx in [ sep_spc . key nmtoken . sep_eq . square quote body quote ] (* We treat attributes according to one of the following three patterns: attval1 : values that must be quoted with single quotes attval2 : values that must be quoted with double quotes attval3 : values that can be quoted with either *) let attributes = let attval1 = attval "'" "'" /[^']*"[^']*/ in (* " *) let attval2 = attval "\"" "\"" /[^"]*'[^"]*/ in let attval3 = attval /['"]/ "\"" /(\\\\|[^'\"])*/ in (* " *) [ label "#attribute" . (attval1|attval2|attval3)+ ] let prolog = [ label "#declaration" . dels "<?xml" . attributes . sep_osp . dels "?>" ] (************************************************************************ * Tags *************************************************************************) (* we consider entities as simple text *) let text_re = /[^<]+/ - /([^<]*\]\]>[^<]*)/ let text = [ label "#text" . store text_re ] let cdata = [ label "#CDATA" . dels "<![CDATA[" . store (char* - (char* . "]]>" . char*)) . dels "]]>" ] (* the value of nmtoken_del is always the nmtoken_key string *) let nmtoken_key = key nmtoken let nmtoken_del = del nmtoken "a" let element (body:lens) = let h = attributes? . sep_osp . dels ">" . body* . dels "</" in [ dels "<" . square nmtoken_key h nmtoken_del . sep_osp . del_end ] let empty_element = [ dels "<" . nmtoken_key . value "#empty" . attributes? . sep_osp . del /\/>[\r?\n]?/ "/>\n" ] let pi_instruction = [ dels "<?" . label "#pi" . [ label "#target" . store pi_target ] . [ sep_spc . label "#instruction" . store pi ]? . sep_osp . del /\?>/ "?>" ] (* Typecheck is weaker on rec lens, detected by unfolding *) (* let content1 = element text let rec content2 = element (content1|text|comment) *) let rec content = element (text|comment|content|empty_element|pi_instruction|cdata) (* Constraints are weaker here, but it's better than being too strict *) let doc = (sep_osp . (prolog | comment | doctype | pi_instruction))* . ((sep_osp . content) | (sep_osp . empty_element)) . (sep_osp . (comment | pi_instruction ))* . sep_osp let lns = doc let filter = (incl "/etc/xml/*.xml") . (incl "/etc/xml/catalog") let xfm = transform lns filter
[+]
..
[-] mailscanner.aug
[edit]
[-] access.aug
[edit]
[-] gshadow.aug
[edit]
[-] activemq_conf.aug
[edit]
[-] gtkbookmarks.aug
[edit]
[-] activemq_xml.aug
[edit]
[-] hostname.aug
[edit]
[-] afs_cellalias.aug
[edit]
[-] mcollective.aug
[edit]
[-] aliases.aug
[edit]
[-] mdadm_conf.aug
[edit]
[-] anacron.aug
[edit]
[-] memcached.aug
[edit]
[-] approx.aug
[edit]
[-] group.aug
[edit]
[-] phpvars.aug
[edit]
[-] apt_update_manager.aug
[edit]
[-] grub.aug
[edit]
[-] puppet.aug
[edit]
[-] aptcacherngsecurity.aug
[edit]
[-] mongodbserver.aug
[edit]
[-] aptconf.aug
[edit]
[-] host_conf.aug
[edit]
[-] aptpreferences.aug
[edit]
[-] hosts.aug
[edit]
[-] aptsources.aug
[edit]
[-] hosts_access.aug
[edit]
[-] authorized_keys.aug
[edit]
[-] htpasswd.aug
[edit]
[-] automaster.aug
[edit]
[-] jettyrealm.aug
[edit]
[-] automounter.aug
[edit]
[-] mke2fs.aug
[edit]
[-] avahi.aug
[edit]
[-] jaas.aug
[edit]
[-] backuppchosts.aug
[edit]
[-] modprobe.aug
[edit]
[-] bbhosts.aug
[edit]
[-] jmxaccess.aug
[edit]
[-] bootconf.aug
[edit]
[-] modules.aug
[edit]
[-] build.aug
[edit]
[-] jmxpassword.aug
[edit]
[-] cachefilesd.aug
[edit]
[-] modules_conf.aug
[edit]
[-] carbon.aug
[edit]
[-] json.aug
[edit]
[-] cgconfig.aug
[edit]
[-] nagiosobjects.aug
[edit]
[-] cgrules.aug
[edit]
[-] kdump.aug
[edit]
[-] channels.aug
[edit]
[-] monit.aug
[edit]
[-] chrony.aug
[edit]
[-] multipath.aug
[edit]
[-] clamav.aug
[edit]
[-] keepalived.aug
[edit]
[-] cobblermodules.aug
[edit]
[-] known_hosts.aug
[edit]
[-] cobblersettings.aug
[edit]
[-] koji.aug
[edit]
[-] collectd.aug
[edit]
[-] mysql.aug
[edit]
[-] cpanel.aug
[edit]
[-] nagioscfg.aug
[edit]
[-] cron.aug
[edit]
[-] krb5.aug
[edit]
[-] crypttab.aug
[edit]
[-] netmasks.aug
[edit]
[-] cups.aug
[edit]
[-] ldif.aug
[edit]
[-] cyrus_imapd.aug
[edit]
[-] networkmanager.aug
[edit]
[-] darkice.aug
[edit]
[-] networks.aug
[edit]
[-] debctrl.aug
[edit]
[-] nrpe.aug
[edit]
[-] desktop.aug
[edit]
[-] ldso.aug
[edit]
[-] device_map.aug
[edit]
[-] lightdm.aug
[edit]
[-] dhclient.aug
[edit]
[-] nginx.aug
[edit]
[-] dhcpd.aug
[edit]
[-] limits.aug
[edit]
[-] dhcpd_140.aug
[edit]
[-] login_defs.aug
[edit]
[-] dns_zone.aug
[edit]
[-] ntpd.aug
[edit]
[-] dnsmasq.aug
[edit]
[-] nsswitch.aug
[edit]
[-] dovecot.aug
[edit]
[-] ntp.aug
[edit]
[-] dpkg.aug
[edit]
[-] odbc.aug
[edit]
[-] dput.aug
[edit]
[-] openshift_http.aug
[edit]
[-] erlang.aug
[edit]
[-] openshift_config.aug
[edit]
[-] ethers.aug
[edit]
[-] pamconf.aug
[edit]
[-] exports.aug
[edit]
[-] logrotate.aug
[edit]
[-] fai_diskconfig.aug
[edit]
[-] openvpn.aug
[edit]
[-] fonts.aug
[edit]
[-] pagekite.aug
[edit]
[-] fstab.aug
[edit]
[-] pam.aug
[edit]
[-] fuse.aug
[edit]
[-] passwd.aug
[edit]
[-] gdm.aug
[edit]
[-] httpd.aug
[edit]
[-] postfix_access.aug
[edit]
[-] inetd.aug
[edit]
[-] pbuilder.aug
[edit]
[-] inifile.aug
[edit]
[-] pg_hba.aug
[edit]
[-] inittab.aug
[edit]
[-] pgbouncer.aug
[edit]
[-] inputrc.aug
[edit]
[-] logwatch.aug
[edit]
[-] interfaces.aug
[edit]
[-] lokkit.aug
[edit]
[-] iproute2.aug
[edit]
[-] mailscanner_rules.aug
[edit]
[-] iptables.aug
[edit]
[-] php.aug
[edit]
[-] iscsid.aug
[edit]
[-] lvm.aug
[edit]
[-] util.aug
[edit]
[-] openshift_quickstarts.aug
[edit]
[-] xinetd.aug
[edit]
[-] postfix_main.aug
[edit]
[-] xendconfsxp.aug
[edit]
[-] postfix_master.aug
[edit]
[-] vfstab.aug
[edit]
[-] postfix_sasl_smtpd.aug
[edit]
[-] vmware_config.aug
[edit]
[-] postfix_transport.aug
[edit]
[-] xml.aug
[edit]
[-] postfix_virtual.aug
[edit]
[-] xorg.aug
[edit]
[-] postgresql.aug
[edit]
[-] xymon.aug
[edit]
[-] properties.aug
[edit]
[-] xymon_alerting.aug
[edit]
[-] protocols.aug
[edit]
[-] yum.aug
[edit]
[-] puppet_auth.aug
[edit]
[-] puppetfile.aug
[edit]
[-] vsftpd.aug
[edit]
[-] puppetfileserver.aug
[edit]
[-] anaconda.aug
[edit]
[-] pylonspaste.aug
[edit]
[-] pythonpaste.aug
[edit]
[-] qpid.aug
[edit]
[-] quote.aug
[edit]
[-] rabbitmq.aug
[edit]
[-] redis.aug
[edit]
[-] webmin.aug
[edit]
[-] reprepro_uploaders.aug
[edit]
[-] resolv.aug
[edit]
[-] rhsm.aug
[edit]
[-] rmt.aug
[edit]
[-] rsyncd.aug
[edit]
[-] rsyslog.aug
[edit]
[-] rx.aug
[edit]
[-] samba.aug
[edit]
[-] schroot.aug
[edit]
[-] securetty.aug
[edit]
[-] sep.aug
[edit]
[-] services.aug
[edit]
[-] shadow.aug
[edit]
[-] shells.aug
[edit]
[-] shellvars.aug
[edit]
[-] shellvars_list.aug
[edit]
[-] simplelines.aug
[edit]
[-] simplevars.aug
[edit]
[-] sip_conf.aug
[edit]
[-] slapd.aug
[edit]
[-] slapd_140.aug
[edit]
[-] smbusers.aug
[edit]
[-] solaris_system.aug
[edit]
[-] soma.aug
[edit]
[-] spacevars.aug
[edit]
[-] splunk.aug
[edit]
[-] squid.aug
[edit]
[-] ssh.aug
[edit]
[-] sshd.aug
[edit]
[-] sshd_140.aug
[edit]
[-] sssd.aug
[edit]
[-] stunnel.aug
[edit]
[-] subversion.aug
[edit]
[-] sudoers.aug
[edit]
[-] sysconfig.aug
[edit]
[-] sysconfig_route.aug
[edit]
[-] sysctl.aug
[edit]
[-] syslog.aug
[edit]
[-] systemd.aug
[edit]
[-] thttpd.aug
[edit]
[-] tuned.aug
[edit]
[-] up2date.aug
[edit]
[-] updatedb.aug
[edit]
[-] wine.aug
[edit]