Das Wiki ist umgezogen und befindet sich nun unter https://wiki.mageia.org/en/Hauptseite-de . Bitte nutzen Sie das neue Wiki.
In der libxslt SRPM gibt es hauptsächlich 3 Dinge, und das Paket devel zu testen.
- libxslt1
- libxslt-devel
- python-libxslt
- xsltproc
#urpmq -i lib64xslt1 Name : lib64xslt1 Version : 1.1.26 Release : 5.1.mga1 Group : System/Libraries Size : 380539 Architecture: x86_64 Source RPM : libxslt-1.1.26-5.1.mga1.src.rpm URL : http://xmlsoft.org/XSLT/ Summary : Library providing XSLT support Description : This C library allows to transform XML files into other XML files (or HTML, text, ...) using the standard XSLT stylesheet transformation mechanism. A xslt processor based on this library, named xsltproc, is provided by the libxslt-proc package. # urpmq -i python-libxslt Name : python-libxslt Version : 1.1.26 Release : 5.1.mga1 Group : Development/Python Size : 155358 Architecture: x86_64 Source RPM : libxslt-1.1.26-5.1.mga1.src.rpm URL : http://xmlsoft.org/XSLT/ Summary : Python bindings for the libxslt library Description : The libxslt-python package contains a module that permits applications written in the Python programming language to use the interface supplied by the libxslt library to apply XSLT transformations. This library allows to parse sytlesheets, uses the libxml2-python to load and save XML and HTML files. Direct access to XPath and the XSLT transformation context are possible to extend the XSLT language with XPath functions written in Python. # urpmq -i xsltproc Name : xsltproc Version : 1.1.26 Release : 5.1.mga1 Group : System/Libraries Size : 25956 Architecture: x86_64 Source RPM : libxslt-1.1.26-5.1.mga1.src.rpm URL : http://xmlsoft.org/XSLT/ Summary : XSLT processor using libxslt Description : This package provides an XSLT processor based on the libxslt C library. It allows to transform XML files into other XML files (or HTML, text, ...) using the standard XSLT stylesheet transformation mechanism.
Das Testen von lib(64)xslt1 geschieht am besten mit einem Chromium-Browser, indem man xhtml-Webseiten öffnet. wie z.B. diese Testseite hier und auch durch Testen mit anderen Werkzeugen - xsltproc und python-libxslt.
xsltproc
xsltproc kann mit folgenden Anweisungen getestet werden [1] (engl.) und dem erzeugen der Dateien cdcatalog.xml und cdcatalog.xsl wie nachfolgend gezeigt:
<?xml version="1.0" encoding="ISO-8859-1"?> <catalog> <cd> <title>Empire Burlesque</title> <artist>Bob Dylan</artist> <country>USA</country> <company>Columbia</company> <price>10.90</price> <year>1985</year> </cd> </catalog>
Es gibt eine erweiterte Version die du hier herunterladen kannst (engl.) - Rechtsklick & Speichern unter.
Die xsl Vorlage sollte unter dem Namen cdcatalog.xsl gespeichert werden, wie nachfolgend angegeben. direkt von hier laden.
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h2>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th>Title</th> <th>Artist</th> </tr> <xsl:for-each select="catalog/cd"> <tr> <td><xsl:value-of select="title"/></td> <td><xsl:value-of select="artist"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
Wenn du die beiden Dateien erstellt hast, kannst du das nachfolgende Kommando verwenden. um zu sehen ob die HTML-Ausgabe erzeugt wird.
$ xsltproc cdcatalog.xsl cdcatalog.xml <html><body> <h2>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th>Title</th> <th>Artist</th> </tr> <tr> <td>Empire Burlesque</td> <td>Bob Dylan</td> </tr> </table> </body></html>
python-libxslt
Verwendest du die beiden gleichen Dateien, cdcatalog.xml und cdcatalog.xsl, so ist es leicht auch python-libxslt zu testen, indem du eine modifizierte Version verwendest, dessen Skript hier zu finden ist und libxml_xslt_transform_example.py genannt wird. Ein direkter Link (Rechtsklick und speichern als) ist hier zu finden
Hast du einmal die Datei erstellt,, mußt du nur noch die Variablen in der Mitte des Skripts ändern, diese Variablen sind die gültigen Fensterpfade.
#!/usr/bin/env python # this is libxml_xslt_transform_example.py """ Example XSLT transformation script that uses the Gnome libxml XML C parser and toolkit On Windows, Python can make use of the libxml2 and libxslt C libraries (http://www.xmlsoft.org/) through the following Python bindings http://users.skynet.be/sbi/libxml-python/. Other bindings can be found here http://codespeak.net/lxml/. The Windows installer includes the C libraries in form of DLLs. Most Linux distributions already include the C libraries. Usage: Python 2.6 Wolfgang Grunberg Arizona Geological Survey 11/09/2009 """ # Library Imports import sys import libxml2 # binding to C library of same name http://www.xmlsoft.org import libxslt # binding to C library of same name http://www.xmlsoft.org # Some variables transform_xslt = "cdcatalog.xsl" source_xml = "cdcatalog.xml" out_xml = "output.xml" def xslt_transform(): styledoc = libxml2.parseFile(transform_xslt) style = libxslt.parseStylesheetDoc(styledoc) doc = libxml2.parseFile(source_xml) # XSLT transform with parameters #result = style.applyStylesheet(doc, {"parameter1":"'1'","parameter2":"'string'"}) # XSLT transform without parameters result = style.applyStylesheet(doc, None) # style.saveResultToFilename(out_xml, result, 0) # save to file result_xml = style.saveResultToString(result) # save to string # cleanup - you are dealing with C libraries style.freeStylesheet() doc.freeDoc() result.freeDoc() print result_xml if __name__=="__main__": xslt_transform()
Sie können dann die nachfolgende Anzeige verfolgen, und sie sollte ähnlich der deinigen sein, wenn die Ausgabe von xsltproc in die Datei output.xml geschrieben wurde:
$ python libxml_xslt_transform_example.py <html><body> <h2>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th>Title</th> <th>Artist</th> </tr> <tr> <td>Empire Burlesque</td> <td>Bob Dylan</td> </tr> </table> </body></html>