æ°ãããã®ã«ã¯åžžã«æ¯æè ãšå察è ãããŠã圌ãã®æéãå€æããããšã¯æããã§ãã ãããã£ãŠãåœæã®å®ææŠäºXSLT vs tplãŸãã¯Smartyã解ãæŸã€ããšã¯ããŸãæå³ããããŸããã§ããã ãããããã·ã¢ã®CMSåžå Žã®ãªãŒããŒã®1人ãenæã®æãŠã匷ãã§æžããŠãããXSLTã®å€§è¡æè¡ãšããŠã®ç Žç£ã«ã€ããŠæžããŠãããç¹å®ã®ã¿ã¹ã¯ã®ã³ã³ããã¹ãã§ã®ã¿æ€èšããæºåãã§ããŠããããšãããããŸããã ãããŠãããã¯ãXSLTã«é¢ããŠåå¿è ã®éçºè ã®å¿ã«æªåœ±é¿ãåãŒããŸãã
äžæ¹ãæè¿ã®ãšãŒãããæ倧ã®ITå±ç€ºäŒCeBIT 㯠ãã»ãšãã©ã®äž»èŠãªè¥¿éšCMSïŒããã¯ã¹åãã©ãããã©ãŒã ãšå éšãã©ãããã©ãŒã ã®äž¡æ¹ïŒãåäžã®çµ±äžæšæºãšããŠXML / XSLTã䜿çšããŠããããšã瀺ããŸããã ããã§ããæ°ãããã¯ãããžãŒã®å®è£ é床ãšããç¹ã§ãã·ã¢ã®ITåžå Žã¯ã西欧ã®ITåžå Žã«ããé ããŠããŸãã ãã®èæ¯ã«åããŠãXSLTãå šäžçã§äœ¿çšããŠããéã«XSLTãåžããšããäºå®ã«ã€ããŠè©±ãããšã¯ãå®å šã«æçšã§æ£ç¢ºã§ã¯ãããŸããã
ãããã£ãŠãHabréã«ç»é²ããç§ã¯ãäžåœã«æ°åã害ããXSLTã®ãªãããªããŒã·ã§ã³ã®è©Šã¿ããå§ããŸãã ç§ã®æèŠã§ã¯ãCMSåžå Žåå è ã®è²¬ä»»ã¯ãæ£ç¢ºã«çŸä»£ã®æè¡ãä¿é²ããç¬èªã®æè¡çæèŠã«ãªãããšã§ãã ãããŠãããšãèªåã§ããŸããããªãã£ããã奜ãã§ã¯ãªãã£ããšããŠãã圌ããä¿¡çšããªãã§ãã ããã ãã§ã«XSLTã«ã€ããŠç¥ã£ãŠãã人ãèªãããšããã§ããŸããã ãã®èšäºã¯ããŸã äž»é¡ã«å«ãŸããŠããªãããŸãã¯çããã人åãã§ãã åæããªã人-ããªããŒãæé ããªãã§ãã ããã 誰ããèªåã®æèŠãè¡šæããæš©å©ãæã£ãŠããŸãã
XSLTãã³ãã¬ãŒããšã³ãžã³ãSmartyããã³å éštplããã¯ã¹åCMSã
XSLTã®æè¡çå©ç¹ã¯ãã¹ãŠãXSLTã«èŠå®ãããŠããåºæ¬æŠå¿µïŒããžãã¹ããžãã¯ãšãã¬ãŒã³ããŒã·ã§ã³ããžãã¯ã®å®å šãªåé¢ïŒã«åºã¥ããŠããŸãã ãã¬ãŒã³ããŒã·ã§ã³ã¢ãã«ãšããžãã¹ããžãã¯ã¢ãã«ãæ··åšãããããšã¯ãããã°ã©ãã®å€§çœªã§ãã ãããŠãéåžžã«äœãè³æ Œãæã€äººã ããããã«åæããŸããã åæã«ãäŸãã°ãéåžžã«äººæ°ã®ããSmartyãã³ãã¬ãŒããšã³ãžã³ã¯ããã¬ãŒã³ããŒã·ã§ã³ã¬ãã«ã§ãã³ãã¬ãŒãã«ããžãã¹ããžãã¯ãå®è£ ã§ããã ãã§ãªããéçºè ãããã«ããã·ã¥ããå³åº§ã®åé¡ã®è¿ éãªè§£æ±ºçãèªããŸãã ããã«ããããã³ãã¬ãŒããšã¹ã¯ãªããéã®ãªã³ã¯ã®éæ§é åãã§ãŒã³ããã®åŸã«ãªããéªã ããŸåŒã«æé·ããæçµçã«å¶åŸ¡äžèœã«ãªããŸãã ãã®çµæãããšãã°ããã³ãã¬ãŒãã§äœ¿çšãããŠãã1ã€ã®ã¡ãœãããå€æŽãããšããã³ãã¬ãŒãå šäœãããã©ãŒã«ãããŸãã
æ¡åŒµã¿ã¹ã¯ã¯ããããžã§ã¯ããæåã«äž»å°ããéçºè ã«ãšã£ãŠããããã¹ãŠããŒãããæžããããšã«å¹æµããŸãã ãã®ãããžã§ã¯ããå¥ã®éçºè ã«ç§»ãããšãäžå¯èœã«ãªããšããäºå®ã¯èšããŸã§ããããŸããã ãããã£ãŠãè€éã§ç¹ã«éæšæºã®å®è£ ã§ã¯ãäœæããããããžã§ã¯ããéçºè ããäžå¯äŸµã«ãªããããçå€å¯èœãªCMSã䜿çšããå©ç¹ã¯Smartyã®äœ¿çšã«ãã£ãŠéšåçã«çžæ®ºãããŸãã ã»ãšãã©ã®å Žåãéçºè ãå€ããããšã¯ãéåžžã«ããŒãããæžãçŽããããšãæå³ããŸããé説çã«èšãã°ããã®å Žåããä»ã®äººãã®ã³ãŒããåŠã¶ã®ã«å¿ èŠãªåŽåãããæçã§ãã æããã«ããã®æ±ºå®ã¯æé©ã§ã¯ãªããããªã倧éã®è²¡æ¿çæ³šå ¥ã®å¥ã®ããããå¿ èŠãšããŸãã
ãããã£ãŠããã®ãããªãã³ãã¬ãŒããšã³ãžã³ã䜿çšããŠäœæãããæ·±å»ãªãããžã§ã¯ãã®ææã³ã¹ããäœãããšã¯èšããŸããã ãã¡ããããããžã§ã¯ããå°èŠæš¡ã®å Žåãéçºè ã®å€æŽã¯äºæ³ãããªãããããã«äœæããŠå¿ããå¿ èŠããããŸããSmartyã®æ¹ãé©ããŠããŸãã
ãŸããSmartyãCMSã§äœ¿çšãããŠããå Žåããæãè ãããã®äžå®ã«æ³šæããããšã¯ã§ããŸãããSmartyãã䜿çšãããäœã¬ãã«ã®äŸµå ¥è ã¯ãããŒã¿ããŒã¹ã¯ãšãªããã³ãã¬ãŒãã«ç°¡åã«çŽæ¥èšè¿°ããã·ã¹ãã å šäœãåæ¢ã§ããŸãã
CMSã®ãã€ãã£ãtpl-templateãšã³ãžã³ã®éèŠãªç¹åŸŽã¯ããã®åæ§ã§ãã ã»ãšãã©ã®å Žåãç¹å®ã®CMSããšã«äœæãããŸãã åã ã®ãã³ãã¬ãŒããšã³ãžã³ã«ã¯ãå®è£ è ã«ããäºå調æ»ãå¿ èŠã§ãããããã«ããéçºã³ã¹ããå¢å ããŸãã
ãã®çµæãå®éã«ã¯ãSmartyã¯ã·ã³ãã«ã§äœ¿ãæ £ããŠããããããŸãæè»æ§ããªããæ¡åŒµå¯èœã§ã¯ãªããéçºè ããå°ãçå€ãããŠãããæœåšçã«å®å šã§ãªãããšã瀺ããŠããŸãã ãããã®æ¬ é¥ã¯ãããžãã¹ããžãã¯ãšããŒã¿è¡šç€ºã¢ãã«ã®æ··ä¹±ãåžžã«äŒŽããŸãã ãããŠããã®èŠ³ç¹ãããSmartyãããã«é¡ãããã®ã¯XSLTãã¯ãããžãŒã®ã¢ã³ãããŒãŒã§ãããå®éã«ã¯ããããã¹ãŠã®æ¬ ç¹ãæé€ããããã«äœæãããŸããã
XSLTã®10åã®åŒæ°
æè¡ã®ä¿¡é Œæ§
1ïŒXSLTã¯ãW3Cã§ãµããŒããããŠããé·å¹Žç¢ºç«ãããæ¥çæšæºã§ãã ããã®éçºè ã®å€§èŠæš¡ãªããŒã ã«ãã£ãŠéçºãããŠããŸãã æè¡ã¯ã質ã®é«ããµããŒãã®ããã«çµ¶ããæ¹åããã³æŽæ°ãããŠããŸãã XSLTã¯äžçäžã§é·ãéã¬ã€ã¢ãŠãæšæºãšããŠèªèãããŠããããã·ã¢ã§ã¯YandexãMy Circleãªã©ã®å€§èŠæš¡ãããžã§ã¯ãã§äœ¿çšãããŠããŸãã
å®å šæ§
2ïŒããžãã¹ããžãã¯ãšããŒã¿ãã¬ãŒã³ããŒã·ã§ã³ã¢ãã«ãå³å¯ã«åé¢ãããŠãããããã¬ã€ã¢ãŠãèšèšè ã¯ããã³ãã¬ãŒãã®ã¿ã«ã¢ã¯ã»ã¹ã§ããå Žåãã·ã¹ãã å šäœãã殺ããããšãã§ããŸãã
æè»æ§
3ïŒXSLTã䜿çšãããšããã§ã«å®è¡ããäœæ¥ã®çµæãåå©çšã§ããŸãã XSLTã§äœæãããã¬ã€ã¢ãŠããããžãã¹ããžãã¯ãšãã®éçºã®æ©èœããµããŒãããªããªããšãèªç±ã«ã¹ã±ãŒã©ãã«ã«ãªããä»ã®ãããžã§ã¯ãã«è»¢éãããŸãã
4ïŒéåžžã®æäœã§ã¯ããã³ãã¬ãŒãã1åã ãäœæãããããžã§ã¯ãéã§äœ¿çšããã ãã§ååã§ãã å®è·µã®äŸïŒããŒãããŒã¹ã¿ãžãªããããŸããŸãªèªåè»ãã©ã³ãã®èªåè»è²©å£²åºã®3ã€ã®ãµã€ããéçºãã泚æãåããŸããã æåã®ãµã€ããäœæããã®ã«çŽ2ãæããããæ°ããæ¹åãèæ ®ããŠ2çªç®ã®ãµã€ãã¯1ãæã§éçºããã3çªç®ã®ãµã€ãã¯2é±éã§äœæãããŸããã ãã¯ãããžãŒèªäœããã§ã«äœæãããŠãããšããäºå®ã«ããããµã€ãã¯ãè£ é£ŸãïŒã€ãŸãããã¶ã€ã³ãå€æŽïŒããããšããã§ããŸããã åé¡ã解決ãããã次ã«æ°ããæ©èœãå°å ¥ããŠãã2ã3åã®æéãããããŸããã
å¯çšæ§ããããããããäœéçºã³ã¹ã
5ïŒHTMLãšCSSã«ã®ã¿ç²ŸéããŠããã¿ã€ãã»ãã¿ãŒã§ããç§ãã¡ã®çµéšã«ããã°ãXSLTãããžã§ã¯ãã®ãŒãããã®éçºæéã¯å¹³åããŠçŽ1ãæåã§ãã ããã«ãXSLTãä»ã®ãããžã§ã¯ãã¿ã¹ã¯ãšã¯å¥ã«ç 究ããå Žåã1é±éåã§ç¿åŸã§ããŸãã æ¯èŒã®ããã«ãåãã¬ã€ã¢ãŠããã¶ã€ããŒã¯ç¹å®ã®CMSã®tpl-templateãšã³ãžã³ãé±å¹³åã§ç¿åŸã§ãããããžã§ã¯ãã®äœæ¥äžã«ç¿åŸãããšåãæãããããŸãã ãã ããXSLTã¬ã€ã¢ãŠããã¶ã€ããŒã¯1åã ãåŠç¿ããå¿ èŠããããåã ã®tpl-templateãšã³ãžã³ã¯åå¥ã®ã¹ã¿ãã£ãååŸããŸãã ãããã£ãŠãXSLTã§æåã®ãããžã§ã¯ããéçºããåŸãå®è£ 段éã§ã®ç¯çŽã«ã€ããŠè©±ãããšãã§ããŸãã
çå€
6ïŒXSLTã¬ã€ã¢ãŠãèšèšè ã¯ãä»ã®èª°ãã®XSLTãã³ãã¬ãŒããåèšèšã§ããŸãã ãã®ãã¯ãããžãŒã¯æšæºã§ãããéçºè éã®ç§»è¡ã¯åé¡ã§ã¯ãããŸãããããã«ããããããžã§ã¯ãã®çå€æ§ãšãããžã§ã¯ãã®ææã³ã¹ãã®å€§å¹ ãªç¯çŽãä¿èšŒãããŸãã
æ¡åŒµæ§
7ïŒXSLTãã³ãã¬ãŒãã®ç·šéã«ã¯ãSmartyäžã«ããå Žåã«ãã³ãã¬ãŒãã§äœ¿çšã§ããããžãã¹ããžãã¯ããã³é¢ä¿æ§é ã®åæãžã®å¹²æžã¯å«ãŸããŸããã ãããã£ãŠãããšãã°ãããžãã¹ããžãã¯ãå€æŽããŠããä»ã®ãã³ãã¬ãŒãã厩å£ããããšã¯ãããŸããã ãã¹ãŠã®éä¿¡ã¯æ§é åãããå€æŽå¯èœã§ãããããããã«ãããäžè²«ããæ¡åŒµã®å¯èœæ§ããã§ã«ç¢ºç«ãããŠããŸãã ãã®ã¢ãããŒãã«ããæ¡åŒµæ§ã¯ãåŽåéçŽæ§ãå€§å¹ ã«è»œæžããåã³ãããžã§ã¯ãã®ææã³ã¹ããåæžãããŸãã
顧客ã®çŸåšã®èŠä»¶ãèãããšããããªãéçºãšæ¡åŒµãå¿ èŠãšããªããããžã§ã¯ããæ³åããããšã¯éåžžã«å°é£ã§ãã XSLTã¯çŸåšããããžã§ã¯ãã®éçºãäºèŠããå°æ¥ã®æ©äŒãæäŸã§ããæé«ã®æšæºã§ãã
8ïŒXML + XSLTã§è§£æ±ºãããããã€ãã®ã¿ã¹ã¯ã¯ãXSLTããªããã°å°ãªããšãç°¡åã§ã¯ãªãå¹ççã§ããããã«èŠããŸãã
ããšãã°ãXSLTã䜿çšãããšãåæ£ãµãŒãã¹ïŒç¹ã«ãWeb 2.0ããã·ã¥ã¢ããã®ã³ã³ããã¹ãã§äžè¬çïŒãæ§ç¯ããããããã䜿çšããŠã¯ã©ã¹ã¿ãŒã·ã¹ãã ãæ§ç¯ãããã§ããŸãïŒãã¡ãããããã¯CMSã«ã¯é©çšãããŸããïŒã XML圢åŒã«åºã¥ãä»ã®ãªãœãŒã¹ãšã®ã³ã³ãã³ãã®äº€æã«ãããèªåã®ãµã€ãã§ä»ã®äººã®ãµãŒãã¹ã䜿çšã§ããŸãã ããã«ããã®ãµãŒãããŒãã£ã®ãµãŒãã¹ããããŠã³ãããå Žåããµã€ãã«ã¯äœãèµ·ãããŸãããããŒã¿ã¯ãã°ããã®éãã£ãã·ã¥ããååŸããããµã€ãã®æ®ãã®ãã«ã¹å šäœã§ãã®ãµãŒãã¹ã衚瀺ãããªããªãå¯èœæ§ããããŸãã äžèšã®Smartyã¢ãããŒãã¯ãéçºãããéæ§é åæ¥ç¶ã®ãããã§ããµãŒãããŒãã£ãµãŒãã¹ãšå ±ã«ãµã€ãå šäœãããŠã³ãããšããäºå®ã«å€§ããè²¢ç®ããå¯èœæ§ããããŸãã
ãã€ãã£ãXMLãµããŒã
9ïŒãããžã§ã¯ãã§é »ç¹ã«äœ¿çšããå¿ èŠãããè±å¯ãªXMLããŒã¿ã¯ãç§ãã¡ã®çŸå®ã§ãã XSLTãã³ãã¬ãŒããšã³ãžã³ã¯ãã€ãã£ãXMLããŒãµãŒã§ãããä»ã®ãã¹ãŠã®ãœãªã¥ãŒã·ã§ã³ã¯èªè»¢è»ã§ãã
ããã©ãŒãã³ã¹ãšé床
10ïŒäžéšã®éçºè ãXSLTãéé£ãããæ¬ ç¹ãã®1ã€ã¯ãããžãã¹ããžãã¯ã®åé¡ã解決ã§ããªãããšã§ãã ãã£ãšéŠ¬é¹¿ãã声æãæ³åããã®ã¯é£ããã ãã®æå³ã§ãXSLTã«ããŒã¿ããŒã¹ããªãŒããŒã¬ã€ããŠé«éåäœãèŠæ±ããããšã¯ãéåžžã®ãã¬ãã®ã¹ããŒã«ãŒã§5.1äºæãã£ã¹ã¯ãåçããŠãã«ããŒãµã©ãŠã³ããèŠæ±ããã®ãšåããããã°ãããŠããŸãã å®çŸ©ã«ãããXSLTã¯ãããè¡ãã¹ãã§ã¯ãªãããã¬ãŒã³ããŒã·ã§ã³ãå®è£ ããããã ãã«äœæãããŸããã ãã ããããžãã¹ããžãã¯ã¯ãããŒãžã衚瀺ããããã«å¿ èŠãªããŒã¿ãæºåããå¿ èŠããããŸãã ãããŠåœŒå¥³ãããããæºåããã°ãããŒãžã«è¡šç€ºããããã®ïŒã»ãšãã©ã®å Žåã10-50補åïŒãéä¿¡ããã ãã§ãããããXSLTã®é床ã«ã€ããŠè³ªåããããšã¯ã§ããŸããã äžåã®è£œåãXMLã«å®å šã«ããŒã¿ããŒã¹å€æããŠããXSLTå€æãé©çšãããšãããã©ãŒãã³ã¹çµæã¯éåžžã«æ²ãããªããŸãã åæã«ãXSLTã®ããŒã¹ã§ããããžãã¹ããžãã¯ãšãã¬ãŒã³ããŒã·ã§ã³ãåé¢ãããšããæŠå¿µã¯å®å šã«åŒ·å§ŠãããŸãã ã»ã«ã²ã€ã»ãªãžã³ãã説æããã¢ãããŒãã§ãçç£æ§ãšã¹ããŒãã®é©ç°ãèŠããªãããšã¯é©ãããšã§ã¯ãããŸããã
XSLTã®æ¬ ç¹ã«ã€ããŠã
æ®å¿µãªãããçæ³çãªäºº/補å/æè¡ã¯ãããŸããã XSLTãäŸå€ã§ã¯ãããŸããã
XSLTã§ãã³ãã¬ãŒãããããã°ãããšããã³ãã¬ãŒãã«ééãããã£ãå Žåãéçºè ããããèŠã€ããŠåé€ããããã«å€å€§ãªåªåãå¿ èŠã«ãªãå ŽåããããŸãã ããã«ãéããããŠããªãã¿ã°ã§ããããã³ãã¬ãŒãå šäœã®åäœäžèœã«ã€ãªãããŸãã ãããã£ãŠãXSLTã§ã¯ãéçºè ãç¹å®ã®æ³šæãæ£ç¢ºæ§ãããã³çŽ°éšãžã®æ³šæãæãå¿ èŠããããŸãã
ãã·ã¢ã§ã®XSLTã®å€§é䜿çšã«é¢ããå¥ã®å¶éã¯ãHTMLã¿ã€ãã»ãã¿ãŒãšæ¯èŒããŠãXSLTã¿ã€ãã»ãã¿ãŒã®è³éãå€§å¹ ã«é«ããšå€ãã®äººãèšã£ãŠããŸãã ããã¯éšåçã«ã¯äºå®ã§ãããå€ãã®ç¹ã§ç¶æ³ã¯äººçºçã«åŒ·å¶ãããŠããŸãã ãã€ãŠããã£ãŒãã®ã¬ã€ã¢ãŠãã¯ãXSLTãå€ãã®äººã«æãããã»ã©ãšããŸããã¯ã§ããã ããããããã¯ãããŒãã«ã¬ã€ã¢ãŠãã«å¯Ÿããå®éã®å©ç¹ã®ããã«ã圌女ãåºãŸãã®ãæ¢ããŸããã§ããã ãããŠãçŽ æŽãããã¬ã€ã¢ãŠãã®ã¹ãã·ã£ãªã¹ãã®äžè¶³ã¯ããã«åžå ŽãåããŸããã ãããã£ãŠãXSLTã³ãŒããŒã®ç»å Žã¯æéã®åé¡ã§ãããXSLTãä»ã®æ¢åã®ãã³ãã¬ãŒããšã³ãžã³ãããæããã«åªããŠããç¹ã§ãã
çµè«
åå¿è ã®éçºè ã«ãšã£ãŠã¯ãå€ãã®å Žåãtplãã³ãã¬ãŒããæ±ãæ¹ãç°¡åã§ãã ãããããããžã§ã¯ãã®éçºã®ç¹å®ã®æ®µéã§ãXSLTã®äœ¿çšã¯æè¡çããã³çµæžçãªèŠ³ç¹ããæ£åœåãããŸãã ãããã£ãŠãéçºè ã«tplãšXSLTã®éã®éžæè¢ãæäŸããå¿ èŠããããŸãã ããããéçºè èªèº«ã¯ãé²æ©ãé¿ãããããXSLTã®å€§éé åžãæéã®åé¡ã§ããããšãç解ããå¿ èŠããããŸãã å šäžçããã®éãé²ãã§ãããç¡èŠãã¹ãã§ã¯ãããŸããã ãããã£ãŠãéçºè ãXSLTã䜿ãå§ããã®ãæ©ããã°æ©ãã»ã©ãå°æ¥å€ãã®ãéã皌ãããšãã§ããŸãã