12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970(*********************************************************************************)(* Stog *)(* *)(* Copyright (C) 2012-2015 INRIA All rights reserved. *)(* Author: Maxence Guesdon, INRIA Saclay *)(* *)(* This program is free software; you can redistribute it and/or modify *)(* it under the terms of the GNU General Public License as *)(* published by the Free Software Foundation, version 3 of the License. *)(* *)(* This program is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU General Public License for more details. *)(* *)(* You should have received a copy of the GNU General Public *)(* License along with this program; if not, write to the Free Software *)(* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA *)(* 02111-1307 USA *)(* *)(* As a special exception, you have permission to link this program *)(* with the OCaml compiler and distribute executables, as long as you *)(* follow the requirements of the GNU GPL in regard to all of the *)(* software in the executable aside from the OCaml compiler. *)(* *)(* Contact: Maxence.Guesdon@inria.fr *)(* *)(*********************************************************************************)(** *)moduleXR=Xtmpl.Rewriteletprefix_ids=letreciterpt=matchtwith|XR.D_|XR.C_|XR.PI_->t|XR.Enode->letatts=node.XR.attsinletatts=matchXR.get_att_cdataatts("","id")withNone->atts|Somes->XR.atts_replace("","id")[XR.cdata(p^s)]attsinletatts=matchXR.get_att_cdataatts("http://www.w3.org/1999/xlink","href")withNone->atts|Somes->letlen=String.lengthsinlets=String.subs1(len-1)(* remove beginning '#' *)inXR.atts_replace("http://www.w3.org/1999/xlink","href")[XR.cdata("#"^p^s)]attsinXR.E{nodewithXR.atts;subs=List.map(iterp)node.XR.subs}initer;;letrecprefix_svg_idsprefixt=matchtwith|XR.D_|XR.C_|XR.PI_->t|XR.E{XR.name=(_,"svg")}ast->prefix_idsprefixt|XR.Enode->XR.E{nodewithXR.subs=List.map(prefix_svg_idsprefix)node.XR.subs};;letfun_prefix_svg_idsstogenv?locattssubs=matchXR.get_att_cdataatts("","prefix")withNone->(stog,subs)|Someprefix->(stog,List.map(prefix_svg_idsprefix)subs);;