никто не встречал готовых реализаций для
Код: Выделить всё
MS Word XML 2 plain HTML через PHP
Код: Выделить всё
MS Word XML 2 plain HTML через PHP
Код: Выделить всё
<?
// Load the XML source
$xml = new DOMDocument;
$xml->load('sample.xml');
$xsl = new DOMDocument;
$xsl->load('translator.xsl');
// Configure the transformer
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl); // attach the xsl rules
$proc->transformToURI($xml, '/tmp/out.html');
$html = implode('', file ('/tmp/out.html'));
print $html;
unlink('/tmp/out.html');
?>
Код: Выделить всё
<?xml version="1.0" encoding="windows-1251"?>
<!--
WordprocessingML to plain XHTML stylesheet
-->
<!-- 2007, Alexey Sberegaev (www.mrlexy.ru) -->
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
<!ENTITY copy "©">
<!ENTITY reg "®">
<!ENTITY trade "™">
<!ENTITY mdash "—">
<!ENTITY ldquo "“">
<!ENTITY rdquo "”">
<!ENTITY pound "£">
<!ENTITY yen "¥">
<!ENTITY euro "€">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:v="urn:schemas-microsoft-com:vml">
<xsl:output method="html" encoding="windows-1251" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251"/>
<title>
<xsl:apply-templates select="w:wordDocument/o:DocumentProperties"/>
</title>
</head>
<body>
<xsl:apply-templates select="w:wordDocument/w:body/wx:sect"/>
</body>
</html>
</xsl:template>
<xsl:template match="w:wordDocument/o:DocumentProperties">
<xsl:value-of select="o:Title"/>
</xsl:template>
<xsl:template match="w:wordDocument/w:body/wx:sect">
<xsl:apply-templates />
</xsl:template>
<!-- HEADINGS and PARA -->
<xsl:template match="w:p">
<xsl:choose>
<xsl:when test="w:pPr/w:pStyle/@w:val=1">
<h1>
<xsl:apply-templates select="w:r | w:hlink" />
</h1>
</xsl:when>
<xsl:when test="w:pPr/w:pStyle/@w:val=2">
<h2>
<xsl:apply-templates select="w:r | w:hlink" />
</h2>
</xsl:when>
<xsl:when test="w:pPr/w:pStyle/@w:val=3">
<h3>
<xsl:apply-templates select="w:r | w:hlink" />
</h3>
</xsl:when>
<xsl:otherwise>
<p>
<xsl:apply-templates select="w:r | w:hlink" />
</p>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Simple formatting (bold, italic, underline), images -->
<xsl:template match="w:r">
<xsl:choose>
<xsl:when test="w:rPr/w:b"><b><xsl:value-of select="w:t" /></b></xsl:when>
<xsl:when test="w:rPr/w:u"><u><xsl:value-of select="w:t" /></u></xsl:when>
<xsl:when test="w:rPr/w:i"><i><xsl:value-of select="w:t" /></i></xsl:when>
<!-- IMG handle section -->
<xsl:when test="w:pict">
<xsl:variable name="imgSrc" select="substring-after(w:pict/v:shape/v:imagedata/@src, 'wordml://')" />
<img src="docimage.phtml?xdocid={$selfDoc}:{$imgSrc}" alt="{w:pict/v:shape/v:imagedata/@o:title}" />
</xsl:when>
<xsl:otherwise><xsl:value-of select="w:t" /></xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Parse hyperlinks -->
<xsl:template match="w:hlink">
<a href="{@w:dest}"><xsl:value-of select="w:r/w:t" /></a>
</xsl:template>
<!-- Parse table (colspan supported, no rowspans) -->
<xsl:template match="w:tbl">
<table width="100%" cellpadding="0" cellspacing="0" border="1">
<xsl:for-each select="w:tr">
<tr>
<xsl:for-each select="w:tc/w:p">
<xsl:if test="../w:tcPr/w:gridSpan/@w:val > 0">
<xsl:text disable-output-escaping="yes"><td colspan=</xsl:text>
<xsl:value-of select="../w:tcPr/w:gridSpan/@w:val" /><xsl:text disable-output-escaping="yes">"></xsl:text>
</xsl:if>
<xsl:if test="not(../w:tcPr/w:gridSpan/@w:val)">
<xsl:text disable-output-escaping="yes"><td></xsl:text>
</xsl:if>
<xsl:apply-templates select="w:r" />
<xsl:text disable-output-escaping="yes"></td></xsl:text>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
Код: Выделить всё
<?xml version="1.0" encoding="windows-1251"?>
<!--
WordprocessingML images extractor
-->
<!-- 2007, Alexey Sberegaev (www.mrlexy.ru) -->
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
<!ENTITY copy "©">
<!ENTITY reg "®">
<!ENTITY trade "™">
<!ENTITY mdash "—">
<!ENTITY ldquo "“">
<!ENTITY rdquo "”">
<!ENTITY pound "£">
<!ENTITY yen "¥">
<!ENTITY euro "€">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:v="urn:schemas-microsoft-com:vml">
<xsl:output method="text" encoding="windows-1251" />
<xsl:template match="/">
<xsl:apply-templates select="w:wordDocument/w:body/wx:sect/wx:sub-section//w:pict//w:binData"/>
</xsl:template>
<xsl:template match="w:pict//w:binData">
<xsl:if test="@w:name=$imgID">
<xsl:apply-templates />
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Код: Выделить всё
$xml = new DOMDocument;
$xml->load("path/to/doc/name.xml");
$xsl = new DOMDocument;
$xsl->load('path/to/mytranslator.xsl');
// Configure the transformer
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl); // attach the xsl rules
//selfDoc - ID документа, по которому
// docimage.phtml (ниже) найдет документ, с которого драть картинки
$proc->setParameter('','selfDoc',sprintf("%08d",$id));
// Plain HTML в переменную
$content=$proc->transformToXML($xml);
if(!trim($content)){
$title=$head='Страница не найдена';
$content='Страница, к которой Вы пытались обратится, недоступна.';
}
Код: Выделить всё
<?
list($document,$image)=split(':',$_GET['xdocid']);
// Load the XML source
$xml = new DOMDocument;
$xml->load("path/to/doc/".$document.'.xml');
$xsl = new DOMDocument;
$xsl->load('path/to/wmimages.xsl');
// Configure the transformer
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl); // attach the xsl rules
$proc->setParameter('','imgID','wordml://'.$image);
$bin=$proc->transformToXML($xml);
if(preg_match("/\.jpg$/",$image)) header("Content-type: image/jpeg");
if(preg_match("/\.gif$/",$image)) header("Content-type: image/gif");
print base64_decode($bin);
?>
сорри, не владею вопросомProFTP писал(а):а скохранить в CVS ?
DHTML (встраиваемые в страницу) редакторы не намного хуже OO или MSW, с возможностью подгрузки картинокОтказался я вобщем от этой затеи )))))))) проще Xinha прикрутить или TinyMCE
непонятненькоRadli писал(а):...
Онлайн редактор не подходят!!! Они пытались в них что то набирать тяжело и неудобно, вылетает каждые 5 минут любой браузер. (Опера, Ие, ФФ) А если из другого редактора всталять текст, то он криво там отображается а про рисунки уж вообще молчу...Да и инет у них по времени...