Pregunta

Estoy tratando de utilizar el XSLTProcessor clase en php para generar XHTML desde un archivo .dita basado en la DITA abierta Toolkit 's archivos XSLT.

El XSLTProcessor está trabajando con simples archivos XML y XSLT (por ejemplo, con las muestras en Wikipedia), pero falla con XSL del Abierto Toolkit.

La parte intresting es que todo funciona bien, si uso de comandos xsltproc de fiesta en el mismo equipo en los mismos archivos (utilicé no hay interruptores).

Por lo tanto, aquí está mi código:

<?php
$sXML = file_get_contents('concepts/tools.xml');
# LOAD XML FILE
$XML = new DOMDocument();
$XML->loadXML( $sXML );

# START XSLT
$xslt = new XSLTProcessor();
$XSL = new DOMDocument();

$XSL->load( 'xsl/dita2xhtml.xsl');
$xslt->importStylesheet( $XSL );
#PRINT
print $xslt->transformToXML( $XML );

Y en lugar de un archivo XHTML consigo una salida como la siguiente:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE span PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<span style="background-color: yellow;"><span style="font-weight: bold">[/concept
     {""}) </span>
<span style="background-color: yellow;"><span style="font-weight: bold">[/concept/title
     {""}) </span>Tools<span style="font-weight: bold"> (title]</span></span>
<span style="background-color: yellow;"><span style="font-weight: bold">[/concept/shortdesc
     {""}) </span>Invest in a good set of tools for doing all kinds of tasks around the house.<span style="font-weight: bold"> (shortdesc]</span></span>
<span style="background-color: yellow;"><span style="font-weight: bold">[/concept/conbody
     {""}) </span><span style="background-color: yellow;"><span style="font-weight: bold">[/concept/conbody/p
     {""}) </span>Useful tools include the following items:<span style="font-weight: bold"> (p]</span></span> (...)

Es sólo la primera parte de la salida, pero yo no quería copiar todo el texto aquí.

Tanto el archivo XSL y dita archivo concepto es del DITA Abierta Toolkit.

Alguna idea de lo que está mal?

¿Fue útil?

Solución

Por último, mi problema está resuelto. El tools.xml tenía una referencia DTD externa

<!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN"

 "../../dtd/technicalContent/dtd/concept.dtd">

wich no estaba cargada por el DOMDocument por defecto, y que causó todos los problemas. Si tiene el mismo problema, hay que utilizar la opción LIBXML_DTDATTR como esto:

$f = 'DITA-OT1.5.1/samples/concepts/tools.xml';
$XML = new DOMDocument();
$XML->load( $f,LIBXML_DTDATTR);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top