March 12, 2010
Amazon.co.jp: YAMAHA P-32DP アルトピアニカ: 家電・カメラ

Meiちゃんママご推薦!

Posted via web from hdknr’s posterous | Comment »

[Today]hdknr: おなかすいた。

hidelafoglia - View my ’hdknr20100311’ photos on Flickriver

02:52  @hdknr: おなかすいた。

03:00  @hdknr: My weight: 68.9 kg. スレンダーマッチョへの道。

03:00  @hdknr: My weight: 71 kg. スレンダーマッチョへの道。

March 11, 2010
Word : *.docx は ZIP形式

rst : Wordに変換する

Using PHP and XSLT to Create a Word 2007 Document

The following PHP code example shows how you transform XML data into the Open XML format. The code uses a DOMDocument object to load the XSLT and create an XSLTProcessor. The XSLTPRocessor’s transformToXML method is called to transform the XML data into the Open XML Wordprocessing format.

//Load the xml data and xslt and perform the transformation.  $xmlDocument = new DOMDocument();  $xmlDocument->load($xmlDataFile);    $xsltDocument = new DOMDocument();  $xsltDocument->load($xsltFile);    $xsltProcessor = new XSLTProcessor();  $xsltProcessor->importStylesheet($xsltDocument);    //After the transformation $newContentNew contains   //the XML data in the Open XML Wordprocessing format.  $newContent =  $xsltProcessor->transformToXML($xmlDocument);  

The following PHP example shows creating the output Word 2007 document. Open XML files are packaged following the Open Packaging Convention and can be treated as Zip files. A ZipArchive object is used to open the Word 2007 document for editing.

//Copy the Word 2007 template document to the output file.  if (copy($sourceTemplate, $outputDocument)) {    //Open XML files are packaged following the Open Packaging   //Conventions and can be treated as zip files when   //accessing their content.  $zipArchive = new ZipArchive();  $zipArchive->open($outputDocument);

The contents of a Word 2007 document are stored in the document.xml file. The following PHP code example shows how to update the Word 2007 document by using the content that contains the XML data by replacing the document.xml file and then closing the ZipArchive to save the changes.

  //Replace the content with the new content created above.  //In the Open XML Wordprocessing format content is stored  //in the document.xml file located in the word directory.  $zipArchive->addFromString("word/document.xml", $newContent);  $zipArchive->close();

XSLTを作るのがかなり大変。でも、rst2xml 用のスタイルシートを1回作れば幸せになれるかもしれない。

Posted via web from 原宿工業大学 | Comment »

rst2a - reStructuredText to Anything

[Today]hdknr: 喉が痛いのは花粉症なのかな。

hidelafoglia - View my ’hdknr20100310’ photos on Flickriver

05:08  @hdknr: 喉が痛いのは花粉症なのかな。

05:33  @hdknr: RT @matsudadoraemon:…

並行複発酵 - Wikipedia

並行複発酵(へいこうふくはっこう)とは、醸造酒の製造過程で起こる発酵の一種であり、酵素によってデンプンブドウ糖に変化する糖化と、ブドウ糖が酵母の働きによってアルコールに変化する発酵とが、同一容器中で同時に行われることをいう。並行複醱酵または並行複醗酵とも書かれる。

日本酒。

Posted via web from hdknr’s posterous | Comment »

Django:フォームのバリデーション

フォームのフィールド名の先頭に “clean_”をつけたメソッドを定義します。


# -*- coding: utf-8 -*-
from django import forms
from django.contrib.formtools.preview import FormPreview
from django.http import HttpResponseRedirect
import re
class MessageForm(forms.Form):
    message = forms.CharField()     def clean_message(self):
        _c_message = self.cleaned_data[‘message’]
        if re.match(“^\d+$”,_c_message) == None:
            raise forms.ValidationError(u’数字を入力してください’)
        else:
            return _c_message

       

アルファベットでPreviewすると、エラー


数字でPreviewだとOK

      

Posted via email from 原宿工業大学 | Comment »

Django: FormPreview : テンプレートファイルの指定

FormPreviewのクラス変数に定義するだけ。


from django import forms
from django.contrib.formtools.preview import FormPreview
from django.http import HttpResponseRedirect class MessageForm(forms.Form):
    message = forms.CharField()

class MessageFormPreview(FormPreview):
    preview_template = ‘djcube/signup_preview.html’
    form_template = ‘djcube/signup.html’     def done(self, request, cleaned_data):
        return HttpResponseRedirect(‘/’)

Posted via email from 原宿工業大学 | Comment »