| Новости | FAQ | Авторы | Документация | В действии | Библиотека |
| Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
Никита Козин 12.08.2006 08:12 / 12.08.2006 08:50
Код честно взял здесь:$oTypograf[^RemoteTypograf::init[ $.entityType[html|xml|no|mixed] $.useBr(0) $.useP(1) $.maxNobr(3) $.parserOutput(0) ]] ^oTypograf.process[$form:text]Код класса:
@CLASS
RemoteTypograf
@init[hParams]
^switch[$hParams.sEntityType]{
^case[html]{$_entityType(1)}
^case[xml]{$_entityType(2)}
^case[no]{$_entityType(3)}
^case[mixed;DEFAULT]{$_entityType(4)}
}
$_useBr(^hParams.useBr.int(1))
$_useP(^hParams.useP.int(1))
$_maxNobr(^hParams.maxNobr.int(3))
$_parserOutput(^hParams.parserOutput.int(0))
# end @init[]
@process[sText][hSOAP;fRemoteTypograf;xProcessTextResult;sTypographed]
$sText[^sText.replace[^table::create{from to
& &^;
< <^;
> >^;}]]
$hSOAP[^hash::create[]]
$hSOAP.Body[<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ProcessText xmlns="http://typograf.artlebedev.ru/webservices/">
<text>$sText</text>
<entityType>$_entityType</entityType>
<useBr>$_useBr</useBr>
<useP>$_useP</useP>
<maxNobr>$_maxNobr</maxNobr>
</ProcessText>
</soap:Body>
</soap:Envelope>]
$fRemoteTypograf[^file::load[binary;http://typograf.artlebedev.ru/webservices/typograf.asmx?parserClient;
$.method[POST]
$.body[^untaint[as-is]{$hSOAP.Body}]
$.charset[utf-8]
]]
$hSOAP.Response[^xdoc::create{^untaint[as-is]{$fRemoteTypograf.text}}]
$hSOAP.Envelope[$hSOAP.Response.documentElement]
$hSOAP.Response.search-namespaces.als[http://typograf.artlebedev.ru/webservices/]
$xProcessTextResult[^hSOAP.Envelope.selectSingle[//als:ProcessTextResult/text()]]
^if(def $xProcessTextResult){
$sTypographed[$xProcessTextResult.nodeValue]
^sTypographed.replace[^table::create{from to
&^; &
<^; <
>^; >
^if($_parserOutput){^; ^^^;}}]
$result[^untaint[as-is]{^sTypographed.trim[]}]
}{
$result[]
}
# end @process[]