Answer the question
In order to leave comments, you need to log in
How to execute arbitrary PHP script during XSL conversion?
<?xml version="1.0" encoding="UTF-8"?>
<project>
<documentation path="/path/to/file.textile" type="textile"/>
<documentation path="/path/to/file.html" type="html"/>
</project>
<documentation/>
with the corresponding HTML? (i.e. the resulting document should contain the result of executing a PHP script, to which the path to the file and its format were passed as parameters)document('php:....')
<documentation/>
replaced by a script call; (2) execute the created documentAnswer the question
In order to leave comments, you need to log in
Perhaps someone will be interested - the problem was solved by writing an extension for the xslt processor and adding it to the style (written in java, used to convert text org.eclipse.mylyn.wikitext
)
Class example:
package ru.lastdragon.ipb.toolkit.xslt;
public final class Converter {
public static String toHtml(String path) {
// .....
}
}
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:converter="ru.lastdragon.ipb.toolkit.xslt.Converter"
extension-element-prefixes="converter"
exclude-result-prefixes="converter">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<xsl:value-of select="converter:toHtml('path/to/file.textile')"/>
</xsl:template>
</xsl:stylesheet>
Do "apply-template" on "documentation".
In the template itself, use the following functionality: ua.php.net/manual/en/xsltprocessor.registerphpfunctions.php
the idea is this:
1. register your function in xslt, which will return the contents of the documentation node
2. change the XSLT style from point 3 so that it runs documentation nodes through our function before use.
if xslt transformation would be started not by ant, but, for example, by a php script, then such a trick could easily be done through registerPHPFunctions ( ru2.php.net/manual/en/xsltprocessor.registerphpfunctions.php )
you can modify the scheme to such, that ant just runs a php cli script that will do the transformation? then everything is decided through registerPHPFunctions
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question