Thread: [phpwebapp-commits] CVS: web_app/boxes/menu/edit/xsl add_subitem.xsl,NONE,1.1 book_list.xsl,NONE,1.1
Brought to you by:
dashohoxha
From: Dashamir H. <das...@us...> - 2004-07-16 07:41:48
|
Update of /cvsroot/phpwebapp/web_app/boxes/menu/edit/xsl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20494/boxes/menu/edit/xsl Added Files: add_subitem.xsl book_list.xsl delete.xsl edit_menu_items.xsl get_id.xsl get_parent_id.xsl menu_items.xsl move_down.xsl move_up.xsl subitems.xsl update.xsl Log Message: --- NEW FILE: add_subitem.xsl --- <?xml version='1.0'?><!-- -*-SGML-*- --> <!-- This file is part of SMEWebApp. SMEWebApp is a web application that displays and edits DocBook documents. Copyright (c) 2004 Dashamir Hoxha, das...@us... SMEWebApp 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; either version 2 of the License, or (at your option) any later version. SMEWebApp 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 SMEWebApp; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> <!-- This transformation appends a new child item to the selected item. It is called with parameters 'id', 'new_id', 'new_caption', like this: xsltproc -stringparam id $id \ -stringparam new_id $new_id \ -stringparam new_caption $new_caption \ add_subitem.xsl menu.xml --> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" version="1.0" encoding="iso-latin-1" omit-xml-declaration="no" standalone="no" indent="yes" /> <xsl:template match="menu[@id=$id]"> <menu id="{@id}"> <xsl:apply-templates /> <item id="{$new_id}" caption="{$new_caption}" /> </menu> </xsl:template> <xsl:template match="item[@id=$id]"> <item id="{@id}" caption="{@caption}" link="null"> <xsl:apply-templates /> <item id="{$new_id}" caption="{$new_caption}" /> </item> </xsl:template> <!-- copy everything else --> <xsl:template match="*|@*"> <xsl:copy> <xsl:apply-templates select="@*" /> <xsl:apply-templates select="node()" /> </xsl:copy> </xsl:template> <!-- ignore text nodes --> <xsl:template match="text()" /> </xsl:transform> --- NEW FILE: book_list.xsl --- <?xml version='1.0'?><!-- -*-SGML-*- --> <!-- This file is part of SMEWebApp. SMEWebApp is a web application that displays and edits DocBook documents. Copyright (c) 2004 Dashamir Hoxha, das...@us... SMEWebApp 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; either version 2 of the License, or (at your option) any later version. SMEWebApp 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 SMEWebApp; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text" indent="no" /> <xsl:template match="menu"> <xsl:text><?php /** * This file contains an array with the list of books and their titles. */ $arr_books = array( </xsl:text> <xsl:apply-templates select="./item" /> <xsl:text>); ?></xsl:text> </xsl:template> <xsl:template match="item"> <xsl:text> "</xsl:text> <xsl:value-of select="@id" /> <xsl:text>" => "</xsl:text> <xsl:value-of select="@caption" /> <xsl:text>", </xsl:text> <xsl:apply-templates /> </xsl:template> <!-- ignore items that have a 'null' link --> <xsl:template match="item[@link='null']"> <xsl:apply-templates /> </xsl:template> <!-- ignore text nodes --> <xsl:template match="text()" /> </xsl:transform> --- NEW FILE: delete.xsl --- <?xml version='1.0'?><!-- -*-SGML-*- --> <!-- This file is part of SMEWebApp. SMEWebApp is a web application that displays and edits DocBook documents. Copyright (c) 2004 Dashamir Hoxha, das...@us... SMEWebApp 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; either version 2 of the License, or (at your option) any later version. SMEWebApp 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 SMEWebApp; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> <!-- This transformation deletes the item with the id given as parameter. It is called with a parameter 'id', like this: xsltproc -stringparam id $id delete.xsl menu.xml --> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" version="1.0" encoding="iso-latin-1" omit-xml-declaration="no" standalone="no" indent="yes" /> <!-- ignore the item with the given id --> <xsl:template match="item[@id=$id]" /> <!-- copy everything else --> <xsl:template match="*|@*"> <xsl:copy> <xsl:apply-templates select="@*" /> <xsl:apply-templates select="node()" /> </xsl:copy> </xsl:template> <!-- ignore text nodes --> <xsl:template match="text()" /> </xsl:transform> --- NEW FILE: edit_menu_items.xsl --- <?xml version='1.0'?><!-- -*-SGML-*- --> <!-- This file is part of SMEWebApp. SMEWebApp is a web application that displays and edits DocBook documents. Copyright (c) 2004 Dashamir Hoxha, das...@us... SMEWebApp 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; either version 2 of the License, or (at your option) any later version. SMEWebApp 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 SMEWebApp; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text" indent="no" /> <xsl:template match="menu"> <xsl:text>// -*-C-*- //tell emacs to use the C mode var EDIT_MENU_ITEMS = [['Select Menu Item', 'javascript:edit(\'</xsl:text><xsl:value-of select="@id"/> <xsl:text>\')', null, </xsl:text> <xsl:apply-templates select="./item"> <xsl:with-param name="indent" select="' '" /> </xsl:apply-templates> <xsl:text>]];</xsl:text> </xsl:template> <xsl:template match="item"> <xsl:param name="indent" select="''" /> <xsl:variable name="link"> <xsl:text>'javascript:edit(\'</xsl:text> <xsl:value-of select="@id" /> <xsl:text>\')'</xsl:text> </xsl:variable> <xsl:value-of select="$indent" /> <xsl:text>['</xsl:text> <xsl:value-of select="@caption"/> <xsl:text>', </xsl:text> <xsl:value-of select="$link"/> <xsl:text>, null</xsl:text> <xsl:choose> <xsl:when test="./item"> <xsl:text>, </xsl:text> <xsl:apply-templates select="./item"> <xsl:with-param name="indent" select="concat(' ', $indent)" /> </xsl:apply-templates> <xsl:value-of select="$indent" /><xsl:text> ], </xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>], </xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:transform> --- NEW FILE: get_id.xsl --- <?xml version='1.0'?><!-- -*-SGML-*- --> <!-- This file is part of SMEWebApp. SMEWebApp is a web application that displays and edits DocBook documents. Copyright (c) 2004 Dashamir Hoxha, das...@us... SMEWebApp 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; either version 2 of the License, or (at your option) any later version. SMEWebApp 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 SMEWebApp; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> <!-- This transformation is used to check whether the given id exists and outputs the id itself if it exists. It is called with a parameter 'id', like this: xsltproc -stringparam id $id get_id.xsl menu.xml --> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text" /> <xsl:template match="*[@id=$id]"> <xsl:value-of select="@id" /> </xsl:template> <!-- ignore text nodes --> <xsl:template match="text()" /> </xsl:transform> --- NEW FILE: get_parent_id.xsl --- <?xml version='1.0'?><!-- -*-SGML-*- --> <!-- This file is part of SMEWebApp. SMEWebApp is a web application that displays and edits DocBook documents. Copyright (c) 2004 Dashamir Hoxha, das...@us... SMEWebApp 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; either version 2 of the License, or (at your option) any later version. SMEWebApp 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 SMEWebApp; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> <!-- This transformation returns the id of the parent item. It is called with a parameter 'id', like this: xsltproc -stringparam id $id get_parent_id.xsl menu.xml --> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text" /> <xsl:template match="item[@id=$id]"> <xsl:value-of select="../@id" /> </xsl:template> <!-- ignore text nodes --> <xsl:template match="text()" /> </xsl:transform> --- NEW FILE: menu_items.xsl --- <?xml version='1.0'?><!-- -*-SGML-*- --> <!-- This file is part of SMEWebApp. SMEWebApp is a web application that displays and edits DocBook documents. Copyright (c) 2004 Dashamir Hoxha, das...@us... SMEWebApp 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; either version 2 of the License, or (at your option) any later version. SMEWebApp 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 SMEWebApp; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text" indent="no" /> <xsl:template match="menu"> <xsl:text>// -*-C-*- //tell emacs to use the C mode var MENU_ITEMS = [ </xsl:text> <xsl:apply-templates select="./item"> <xsl:with-param name="indent" select="' '" /> </xsl:apply-templates> <xsl:text>];</xsl:text> </xsl:template> <xsl:template match="item"> <xsl:param name="indent" select="''" /> <xsl:variable name="link"> <xsl:apply-templates select="." mode="get-link" /> </xsl:variable> <xsl:value-of select="$indent" /> <xsl:text>['</xsl:text> <xsl:value-of select="@caption"/> <xsl:text>', </xsl:text> <xsl:value-of select="$link"/> <xsl:text>, null</xsl:text> <xsl:choose> <xsl:when test="./item"> <xsl:text>, </xsl:text> <xsl:apply-templates select="./item"> <xsl:with-param name="indent" select="concat(' ', $indent)" /> </xsl:apply-templates> <xsl:value-of select="$indent" /><xsl:text> ], </xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>], </xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="item[@link='null']" mode="get-link"> <xsl:value-of select="'null'" /> </xsl:template> <xsl:template match="item[not(@link='null')]" mode="get-link"> <xsl:value-of select="'not-null'" /> <xsl:text>'</xsl:text> <xsl:value-of select="@link" /> <xsl:text>'</xsl:text> </xsl:template> <xsl:template match="item[not(@link)]" mode="get-link"> <xsl:text>'javascript:book(\'</xsl:text> <xsl:value-of select="@id" /> <xsl:text>\')'</xsl:text> </xsl:template> </xsl:transform> --- NEW FILE: move_down.xsl --- <?xml version='1.0'?><!-- -*-SGML-*- --> <!-- This file is part of SMEWebApp. SMEWebApp is a web application that displays and edits DocBook documents. Copyright (c) 2004 Dashamir Hoxha, das...@us... SMEWebApp 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; either version 2 of the License, or (at your option) any later version. SMEWebApp 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 SMEWebApp; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> <!-- This transformation moves down the item with the given id. It is called with a parameter 'id', like this: xsltproc -stringparam id $id move_down.xsl menu.xml --> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" version="1.0" encoding="iso-latin-1" omit-xml-declaration="no" standalone="no" indent="yes" /> <xsl:template match="item"> <xsl:choose> <xsl:when test="@id=$id and following-sibling::item"> <xsl:copy-of select="following-sibling::item[1]" /> </xsl:when> <xsl:when test="preceding-sibling::item[1]/@id=$id"> <xsl:copy-of select="preceding-sibling::item[1]" /> </xsl:when> <xsl:otherwise> <xsl:copy> <xsl:copy-of select="@*" /> <xsl:apply-templates /> </xsl:copy> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- copy everything else --> <xsl:template match="*|@*"> <xsl:copy> <xsl:apply-templates select="@*" /> <xsl:apply-templates select="node()" /> </xsl:copy> </xsl:template> </xsl:transform> --- NEW FILE: move_up.xsl --- <?xml version='1.0'?><!-- -*-SGML-*- --> <!-- This file is part of SMEWebApp. SMEWebApp is a web application that displays and edits DocBook documents. Copyright (c) 2004 Dashamir Hoxha, das...@us... SMEWebApp 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; either version 2 of the License, or (at your option) any later version. SMEWebApp 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 SMEWebApp; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> <!-- This transformation moves up the item with the given id. It is called with a parameter 'id', like this: xsltproc -stringparam id $id move_up.xsl menu.xml --> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" version="1.0" encoding="iso-latin-1" omit-xml-declaration="no" standalone="no" indent="yes" /> <xsl:template match="item"> <xsl:choose> <!-- if the item next to this one is the selected one, --> <!-- then copy the next item instead of this one --> <xsl:when test="following-sibling::item[1]/@id=$id"> <xsl:copy-of select="following-sibling::item[1]" /> </xsl:when> <!-- if this item is the selected one and there exists a previous --> <!-- item, then copy the previous item instead of this one --> <xsl:when test="@id=$id and preceding-sibling::item"> <xsl:copy-of select="preceding-sibling::*[1]" /> </xsl:when> <!-- otherwise copy this item and apply templates --> <xsl:otherwise> <xsl:copy> <xsl:copy-of select="@*" /> <xsl:apply-templates /> </xsl:copy> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- copy everything else --> <xsl:template match="*|@*"> <xsl:copy> <xsl:apply-templates select="@*" /> <xsl:apply-templates select="node()" /> </xsl:copy> </xsl:template> </xsl:transform> --- NEW FILE: subitems.xsl --- <?xml version='1.0'?><!-- -*-SGML-*- --> <!-- This file is part of SMEWebApp. SMEWebApp is a web application that displays and edits DocBook documents. Copyright (c) 2004 Dashamir Hoxha, das...@us... SMEWebApp 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; either version 2 of the License, or (at your option) any later version. SMEWebApp 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 SMEWebApp; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> <!-- Outputs subitems of the selected item --> <!-- Is called with a parameter 'id', like this: --> <!-- xsltproc -stringparam id $item_id subitems.xsl menu.xml --> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text" indent="no" /> <!-- Find the item with the given id and then output the id and caption for this item and for its subitems. --> <xsl:template match="*[@id=$id]"> <xsl:value-of select="concat(@id, ' ', @caption)" /> <xsl:text> </xsl:text> <xsl:for-each select="./item"> <xsl:value-of select="concat(@id, ' ', @caption)" /> <xsl:text> </xsl:text> </xsl:for-each> </xsl:template> <!-- ignore text nodes --> <xsl:template match="text()" /> </xsl:transform> --- NEW FILE: update.xsl --- <?xml version='1.0'?><!-- -*-SGML-*- --> <!-- This file is part of SMEWebApp. SMEWebApp is a web application that displays and edits DocBook documents. Copyright (c) 2004 Dashamir Hoxha, das...@us... SMEWebApp 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; either version 2 of the License, or (at your option) any later version. SMEWebApp 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 SMEWebApp; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> <!-- This transformation updates the id and caption of the selected item. It is called with parameters 'id', 'new_id', 'new_caption', like this: xsltproc -stringparam id $id \ -stringparam new_id $new_id \ -stringparam new_caption $new_caption \ update.xsl menu.xml --> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" version="1.0" encoding="iso-latin-1" omit-xml-declaration="no" standalone="no" indent="yes" /> <xsl:template match="item[@id=$id]"> <xsl:choose> <xsl:when test="./item"> <item id="{$new_id}" caption="{$new_caption}" link="null"> <xsl:apply-templates /> </item> </xsl:when> <xsl:otherwise> <item id="{$new_id}" caption="{$new_caption}"/> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- copy everything else --> <xsl:template match="*|@*"> <xsl:copy> <xsl:apply-templates select="@*" /> <xsl:apply-templates select="node()" /> </xsl:copy> </xsl:template> <!-- ignore text nodes --> <xsl:template match="text()" /> </xsl:transform> |