2007年1月發(fā)表,1月24日由Quester中文翻譯,原文鏈接:http://logoorange.com/logo-design.php
11 trends that will define Logo design in 2007
Everyone wants to set the curve when it comes to style. No one wants to design out of a book of trends, but nevertheless, they emerge.
Take a peek at the following 11 Logo design trends that we think will define the look of 2007.
11種趨勢將定義2007年的Logo設計
每個設計師都想在某一風格成為流行前把握它。沒有人愿意自己的設計和流行趨勢脫節(jié)。但是無論如何,這些趨勢總是會露出端倪。
讓我們一同來窺探一下這11種我們認為的2007年標志設計的趨勢密碼。
![]() |
1. Talk Boxes This is an outgrowth of last year's trend, even though these boxes have been around a few years now. |
|
1. 對話泡泡 這是一種去年的流行風格的衍生,盡管這些泡泡已經(jīng)玩了好幾年了。 |
![]() |
2. Clouds Everyone remembers a time when they laid on their back in the grass, staring at the clouds daydreaming or finding images in their puffs. |
![]() |
2. 云狀物 每個人都有那些仰面躺在草地上的時候,望著云朵發(fā)白日夢或者從騰云變換中尋找圖案的記憶。 |
![]() |
3. Reflections Mirror, mirror, on the wall, what's the hottest trend of all? It might just be reflections. With Apple leading the way, looking like all their graphics were set on a shiny table, others are sure to follow. Dubbed by some as ?the new drop shadow,? reflections are taking over, especially on the web. The reflections might be skewed, such as in the Logo for blinklist, indicating the location of some light source, invisible to the onlooker, but effective in creating even more of a sense of a whole different world the Logo is in. |
|
3. 反射效果(鏡像效果) 魔鏡魔鏡告訴我,什么是最熱的潮流??? 它可能就是“反射效果”。蘋果最先開始倡導的,把什么東西都弄得好像放在光滑閃亮的桌面上,其他人就開始跟風。有人給它起了個綽號叫什么來著?“新的下拉 陰影”(意思和以前的“下拉陰影”效果一樣滿天飛)。 “反射效果”全面霸占,尤其是在網(wǎng)上。反射效果可以是不對稱的,就像 blinklist 的Logo一樣,弄出一些光的效果卻讓你找不到光源,但對于創(chuàng)造擁有更多“完全不同的世界”感覺的Logo是有效而時尚的。 |
![]() |
4. Rectangle In a graphic world where you can do nearly anything, some companies are keeping it simple with shaded rectangles. Their Logo, in a contrasting white, pops out from the background. Shadow boxes have historically been a sign of amateurish design, but this new generation of effective Logos has shown that good design will always be in style. With the popularity of rounded corners, these Logos stand out with (oh no!) sharp edges and right angles. In some occasions, such as with the blurb Logo, the rectangle can represent an image. Blurb used their blue shadow behind their name to symbolize a book, as they are in the book publishing business. |
|
4. 長方形 在圖形世界里,你幾乎可以做任何事情,但有些公司只使用簡單的帶邊框的長方形。他們的Logo,從高反差的白色背景上“跳”出來。相框一樣的長方形 容易給人“業(yè)余設計水平”的感覺,但是新生的有活力的這些Logo,表明了好的設計永遠都是有品味的。與人氣極旺的圓角風格同時,這些Logo因有著銳利 的邊緣和適當?shù)膬A斜角度而特別顯眼(不是吧!)。在某些場合,就像 Blurb的Logo,長方形可以用于扮演一個形象。Blurb 用藍色的圖形放在名字后面來代表一本書,因為他們做的是圖書出版業(yè)務。 |
?
|
5. 3d Puffies With these new puffed-up Logos, you don't know whether to click on them or bounce on them. Now that the industry has overcome the production issues of gradients, designers seem to prefer air-popped graphics to the flat drawings of yore. Even desktop icons these days seem to have a rounded feel, like you might pop one with one good hard double-click. It's a 2D world out there in Internet land, and these 3D images really make Web pages and Logos jump out of the page, to where you feel you could run your hands over the computer screen and feel their bumps and curves. |
|
5. 立體發(fā)泡物 這些新出現(xiàn)的圓鼓鼓發(fā)泡Logo,讓你搞不懂到底是在上面點擊還是在上面彈跳。自從工業(yè)生產(chǎn)克服了“漸變色”的難題,設計師們就似乎熱衷于將“立體 彈出”的圖像加到以往的平面圖樣中。甚至桌面圖標在最近也看起來有圓乎乎的感覺,就像你用力一點擊它就會彈得老高。二維的世界已經(jīng)從互聯(lián)網(wǎng)走開了,三維的 圖像的確讓網(wǎng)頁和Logo“跳出”頁面,進入一個你可以用手指滿屏幕去感覺那些凹凸不平和曲線的新世界。 |
|
6. Hot Dogs These cute little Tic Tacs of color are popping up all over the design world. Like many abstract symbols, the hot dogs can be used to mean many different things. Sometimes they denote movement or sound, such as in the Logo for Snap. These lines, reminiscent of those drawn out of shocked cartoon people by children everywhere, can denote an idea, a feeling or a literal meaning. But no matter how they're used in design, they are a powerful symbol of an upbeat emotion. |
|
6. 熱狗腸 這些色彩和彈出的可愛小把戲遍布了整個設計界。像許多抽象符號一樣,熱狗腸可以用來表示許多不同的東西。又是他們表示聲音或運動的 警示,就像Snap的Logo里那樣。那些輻射的線條,讓人想起隨處可見的小孩子畫的 大吃一驚的 卡通人物。它能表示一種想法,一種感覺或者只是一種 字面上的意義。但不管它們用在設計中是為什么,它們都是一種有強烈表現(xiàn)力的符號來象征 樂觀的態(tài)度。 |
|
7. Transmission beam With satellite tv and radio and wireless everything all the rage in the new millennium, a transmission beams are a quick way to show that they are on the cutting edge of technology. Many companies who use this Logo trend deal in internet information. Part of what many of these companies are doing on the internet is taking user (or customer) information and sharing it with the world. The transmission beam, starting with a single dot (to represent the user), shows their ideas spreading out. It's the perfect symbol for publishing companies or blog sites. |
|
7. 發(fā)射電波 衛(wèi)星電視,電臺和無線的東東在新紀元里遍地開花,用發(fā)射電波是最快捷方式來表明他們是站在科技的最前沿。用這種Logo的許多公司都在做互聯(lián)網(wǎng)信息 生意。他們中間有許多公司做的是在互聯(lián)網(wǎng)上獲取用戶(客戶)資料然后分享給全世界。無線電波,始發(fā)于一個“點”(代表用戶),體現(xiàn)他們的理念在傳播。對于 出版公司和博 |
?
|
8. People AOL's little man has some company, with others creating buddies to include in their Logos. For companies that bring people together, these genderless little people are shown in pairs or groups. They provide a visual indicator of coming together. Others show just one of these symbols, usually as an avatar for their customer. Anyone looking for other people can be sure they've found them when they see a Logo with a buddy. |
|
8. 人形 美國在線的“小人”已有了幾個軍團,和其他正在創(chuàng)建的好友一起都歸屬在它的Logo旗下。軍團將人聚在一起,把這些搞不清性別的人成對或成組排列。 他們?yōu)椤熬墼谝黄稹碧峁┝诉@樣一個視覺指示。有些公司的Logo只展示符號中的一個,這通常作為他們客戶的偶像。任何想找人的人,當他們看到有這個 Logo的哥們,就能確信自己可以找到隊伍。 |
![]() |
9. Transparency Transparency is still hot. Again, many may gasp as the mere though of using a shadow, but this updated version is nothing like the shadow boxes that have plagued generic design. These Logos invoke images of blending together. Some, like the two transmission bubbles that seem to be popping out the little people in the BlueDot Logo, can symbolize communication, or a sort of overlapping and blending of ideas. Others are a Venn diagram, showing where the company fits, such as Zopa. |
|
9. 透明效果 透明效果仍舊熱門。強調一下,很多人的需求只不過是加上個相框樣的東東,但是這個“升級版”一點都不象相框那樣是令人厭倦的普通設計。這些Logo 讓圖像混合在一起。有些,象是兩個傳送的泡泡,它們看起來象是要把“小人”彈出來(見BlueDot的Logo),它可以象征溝通,或者 觀念的混合 和 重疊的排序。另外的看起來象“交集圖”(Venn diagram),展現(xiàn)出什么是公司的業(yè)務范圍,就像 Zopa。 |
![]() |
10. Outlines (I think this is another way to add sophistication, 3d effect to a Logo) |
?
![]() |
10. 輪廓線 (我想這是另外一個方法來錦上添花,弄點立體效果到Logo上。) |
![]() |
11. Punctuation From smiley faces to complex illustrations, every day punctuation has gained a new life in the tech typing world of the internet. While some used to only be used to denote the f-word, they're now used in the young on-line world on instant messaging, e-mailing and teen-speak in general. Now, these symbols have jumped out of instant messaging and onto billboards as of late, with their meanings left to the imagination of customers. |
![]() |
11. 標點符號 從笑臉圖案到復雜插圖,在互聯(lián)網(wǎng)的文字輸入世界里,標點符號每天都會獲得新生。當某些人習慣于只用 F-word(粗俗語言,F(xiàn)xxk字頭的詞匯)來表達時,它們現(xiàn)在就被年輕人用在即時聊天,E-Mail和小青年們的日常對話里。現(xiàn)在這些符號從即時聊天 軟件和聊天室里蹦出來,帶著它們的涵義留給用戶無限的想像空間。 |
3.?將compass1.0解壓到一個合適的目錄,我們的工作目錄是d:\develop\compass1.0
4.?我們是在eclipse環(huán)境下實現(xiàn)當前要求的,所以建議你也安裝一個eclipse 3.2。
5.?首先我們在eclipse中建立了一個java工程,名為mycompass。
6.?然后我們在工程目錄中建立了一個lib目錄,用來存放本次工程所需要的所有compass和其它相關的庫文件,并將他們設置為當前工程構建路徑中需要的庫文件。所有這些文件可以在compass的安裝目錄的lib目錄找到。
??下面是我們的庫文件列表:
?
7.?建立了Article表的pojo類。
??package com.darkhe.sample.mycompass;
??
??// Generated 2006-8-2 10:57:06 by Hibernate Tools 3.2.0.beta6a
??
??import java.util.Date;
??
??/**
?? * Article generated by hbm2java
?? */
??public class Article implements java.io.Serializable {
??
???// Fields???
??
???private long articleId;
??
???private Long personInfoId;
??
???private String articleTitle;
??
???private Date publishDate;
??
???private String summary;
??
???private String content;
??
???private String keyList;
??
???// Constructors
??
???/** default constructor */
???public Article() {
???}
??
???/** minimal constructor */
???public Article(long articleId) {
????this.articleId = articleId;
???}
??
???/** full constructor */
???public Article(long articleId, Long personInfoId, String articleTitle,
?????Date publishDate, String summary, String content, String keyList) {
????this.articleId = articleId;
????this.personInfoId = personInfoId;
????this.articleTitle = articleTitle;
????this.publishDate = publishDate;
????this.summary = summary;
????this.content = content;
????this.keyList = keyList;
???}
??
???// Property accessors
???public long getArticleId() {
????return this.articleId;
???}
??
???public void setArticleId(long articleId) {
????this.articleId = articleId;
???}
??
???public Long getPersonInfoId() {
????return this.personInfoId;
???}
??
???public void setPersonInfoId(Long personInfoId) {
????this.personInfoId = personInfoId;
???}
??
???public String getArticleTitle() {
????return this.articleTitle;
???}
??
???public void setArticleTitle(String articleTitle) {
????this.articleTitle = articleTitle;
???}
??
???public Date getPublishDate() {
????return this.publishDate;
???}
??
???public void setPublishDate(Date publishDate) {
????this.publishDate = publishDate;
???}
??
???public String getSummary() {
????return this.summary;
???}
??
???public void setSummary(String summary) {
????this.summary = summary;
???}
??
???public String getContent() {
????return this.content;
???}
??
???public void setContent(String content) {
????this.content = content;
???}
??
???public String getKeyList() {
????return this.keyList;
???}
??
???public void setKeyList(String keyList) {
????this.keyList = keyList;
???}
??
??}
8.?建立hibernate的pojo到數(shù)據(jù)表映射文件
?<?xml version="1.0"?>
?<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
?"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
?<!-- Generated 2006-8-2 10:57:07 by Hibernate Tools 3.2.0.beta6a -->
?<hibernate-mapping>
??? <class name="com.darkhe.sample.mycompass.Article" table="article" catalog="freedom">
??????? <comment></comment>
??????? <id name="articleId" type="long">
??????????? <column name="ArticleID" />
??????????? <generator class="assigned" />
??????? </id>
??????? <property name="personInfoId" type="java.lang.Long">
??????????? <column name="PersonInfoID">
??????????????? <comment></comment>
??????????? </column>
??????? </property>
??????? <property name="articleTitle" type="string">
??????????? <column name="ArticleTitle" length="200">
??????????????? <comment></comment>
??????????? </column>
??????? </property>
??????? <property name="publishDate" type="timestamp">
??????????? <column name="PublishDate" length="19">
??????????????? <comment></comment>
??????????? </column>
??????? </property>
??????? <property name="summary" type="string">
??????????? <column name="Summary" length="65535">
??????????????? <comment></comment>
??????????? </column>
??????? </property>
??????? <property name="content" type="string">
??????????? <column name="Content">
??????????????? <comment></comment>
??????????? </column>
??????? </property>
??????? <property name="keyList" type="string">
??????????? <column name="KeyList" length="65535">
??????????????? <comment></comment>
??????????? </column>
??????? </property>
??? </class>
?</hibernate-mapping>
9.?開始配置compass,首先是compass的系統(tǒng)配置文件 mycompass.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<compass-core-config
?xmlns="http://www.opensymphony.com/compass/schema/core-config"
?xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
?xsi:schemaLocation="http://www.opensymphony.com/compass/schema/core-config
?????????? http://www.opensymphony.com/compass/schema/compass-core-config.xsd">
?<compass name="default"> <!—這個名字隨你取了,但它是必須的-->
??<connection>
???<file path="target" /> <!—這里是索引文件的存放路徑,我們設置的是當前工程的相對路徑target-?
??</connection>
??<searchEngine>
??? <!-- 因是使用自己的分詞算法,所以這里的類型必須是CustomAnalyzer -->
????????? <analyzer name="MMAnalyer" type="CustomAnalyzer" analyzerClass="jeasy.analysis.MMAnalyzer">
????????????? <stopWords>
????????????????? <stopWord value="test" />
????????????? </stopWords>
????????? </analyzer>
????? </searchEngine>
?</compass>
</compass-core-config>
?在上面的配置中,我們使用的我們選用的一個中文分詞算法庫,你可以用compass自帶的。具體compass提供了哪些分詞算法,請查閱compass的手冊。
10.?然后是mycompass.cmd.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE compass-core-meta-data PUBLIC
??? "-//Compass/Compass Core Meta Data DTD 1.0//EN"
??? "http://www.opensymphony.com/compass/dtd/compass-core-meta-data.dtd">
<compass-core-meta-data>
<!-- 定義一個實體和字段組-->
??? <meta-data-group id="mycompass" displayName="My Compass">
???
??????? <descrīption>Mycompass Meta Data</descrīption>??????
??????? <uri>http://com/darkhe/sample/mycompass</uri>
???
???????
<!-- 申明所有需要檢索的實體-->???????
??????? <alias id="Article" displayName="Article">
??????????? <descrīption>Article alias</descrīption>
??????????? <uri>http://com/darkhe/sample/mycompass/alias/Article</uri>
??????????? <name>Article</name>
??????? </alias>
???????
?<!-- 申明所有需要檢索的屬性或者字段,而不管這些屬性或者字段是哪個實體的 -->???????
??????? <meta-data id="ArticleTitle" displayName="ArticleTitle">
??????????? <descrīption>ArticleTitle</descrīption>
??????????? <uri>http://com/darkhe/sample/mycompass/alias/ArticleTitle</uri>
??????????? <name>ArticleTitle</name>
??????? </meta-data>
???????
??????? <meta-data id="PublishDate" displayName="PublishDate">
??????????? <descrīption>PublishDate</descrīption>
??????????? <uri>http://com/darkhe/sample/mycompass/alias/PublishDate</uri>
??????????? <name format="yyyy-MM-dd hh:mm:ss">date</name>
??????? </meta-data>
???????
??????? <meta-data id="Summary" displayName="Summary">
??????????? <descrīption>Summary</descrīption>
??????????? <uri>http://com/darkhe/sample/mycompass/alias/Summary</uri>
??????????? <name>Summary</name>
??????? </meta-data>
???????
??????? <meta-data id="Content" displayName="Content">
??????????? <descrīption>Content</descrīption>
??????????? <uri>http://com/darkhe/sample/mycompass/alias/Content</uri>
??????????? <name>Content</name>
??????? </meta-data>
??????? <meta-data id="KeyList" displayName="KeyList">
??????????? <descrīption>KeyList</descrīption>
??????????? <uri>http://com/darkhe/sample/mycompass/alias/KeyList</uri>
??????????? <name>KeyList</name>
??????? </meta-data>???????
???????????????????????
??? </meta-data-group>
???
</compass-core-meta-data>
11.?再是mycompass.cpm.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE compass-core-mapping PUBLIC
??? "-//Compass/Compass Core Mapping DTD 1.0//EN"
??? "http://www.opensymphony.com/compass/dtd/compass-core-mapping.dtd">
<!-- 這里的包名必須和pojo的包名一致 -->
<compass-core-mapping package="com.darkhe.sample.mycompass">
<!-- 定義實體及其字段的對應關系 -->
<!-- 注意實體及其字段的名稱的大小寫應當與pojo對象一致,而不是與數(shù)據(jù)庫一致
? 關于pojo與數(shù)據(jù)庫的對應表的一致性關系由hibernate的映謝文件定義,而不是這個文件
? 當前映射文件只定義compass與hibernate的關系 -->
?<class name="Article" alias="${mycompass.Article}">
??<id name="ArticleId" />
??
??<property name="ArticleTitle">
???<meta-data>${mycompass.ArticleTitle}</meta-data>
??</property>
??<property name="PublishDate">
???<meta-data>${mycompass.PublishDate}</meta-data>
??</property>
??<property name="Summary">
???<meta-data>${mycompass.Summary}</meta-data>
??</property>
??<property name="Content">
???<meta-data>${mycompass.Content}</meta-data>
??</property>
??<property name="KeyList">
???<meta-data>${mycompass.KeyList}</meta-data>
??</property>
?</class>
?</compass-core-mapping>
12.?log4j.properties
log4j.rootLogger=WARN, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p %c - %m%n
log4j.logger.org.compass=INFO
13.?jdbc.properties
# Properties file with JDBC-related settings.
# Applied by PropertyPlaceholderConfigurer from "applicationContext-*.xml".
# Targeted at system administrators, to avoid touching the context XML files.
jdbc.driverClassName=com.mysql.jdbc.Driver
#jdbc.driverClassName=org.hsqldb.jdbcDriver
#jdbc.url=jdbc:hsqldb:hsql://localhost:9001
jdbc.url=jdbc:mysql://localhost:3306/testdb
jdbc.username=test
jdbc.password=test
# Property that determines the Hibernate dialect
# (only applied with "applicationContext-hibernate.xml")
#hibernate.dialect=org.hibernate.dialect.HSQLDialect
hibernate.dialect=org.hibernate.dialect.MySQLDialect
14.?最后是applicationContext-hibernate.xml,這里集中配置了compass如何與spring與hibernate結合的。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<!--
?- Application context definition for Petclinic on Hibernate.
-->
<beans>
?<!-- ========================= RESOURCE DEFINITIONS ========================= -->
?<!-- Configurer that replaces ${...} placeholders with values from a properties file -->
?<!-- (in this case, JDBC-related settings for the dataSource definition below) -->
?<bean id="propertyConfigurer"
??class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
??<property name="location">
???<value>classpath:jdbc.properties</value>
??</property>
?</bean>
?<!-- Local DataSource that works in any environment -->
?<!-- Note that DriverManagerDataSource does not pool; it is not intended for production -->
?<!-- See JPetStore for an example of using Commons DBCP BasicDataSource as alternative -->
?<!-- See Image Database for an example of using C3P0 ComboPooledDataSource as alternative -->
?<bean id="dataSource"
??class="org.springframework.jdbc.datasource.DriverManagerDataSource">
??<property name="driverClassName">
???<value>${jdbc.driverClassName}</value>
??</property>
??<property name="url">
???<value>${jdbc.url}</value>
??</property>
??<property name="username">
???<value>${jdbc.username}</value>
??</property>
??<property name="password">
???<value>${jdbc.password}</value>
??</property>
?</bean>
?<!-- JNDI DataSource for J2EE environments -->
?<!--
??<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
??<property name="jndiName"><value>java:comp/env/jdbc/petclinic</value></property>
??</bean>
?-->
?<!-- Hibernate SessionFactory -->
?<bean id="sessionFactory"
??class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
??<property name="dataSource">
???<ref local="dataSource" />
??</property>
??<property name="mappingResources">
???<list>
????<value>
?????com/darkhe/sample/mycompass/Article.hbm.xml <!-- 這里是hibernate里需要的數(shù)據(jù)映射文件 -->
????</value>
???</list>
??</property>
??<property name="hibernateProperties">
???<props>
????<prop key="hibernate.dialect">
?????${hibernate.dialect}
????</prop>
????<prop key="hibernate.show_sql">false</prop>
????<prop key="hibernate.generate_statistics">true</prop>
???</props>
??</property>
??<property name="eventListeners">
???<map>
????<entry key="merge">
?????<bean
??????class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener" />
????</entry>
???</map>
??</property>
?</bean>
?<!-- COMPASS START -->
?<bean id="compass" class="org.compass.spring.LocalCompassBean">
??<property name="resourceLocations">
???<list>
????<value>classpath:mycompass.cmd.xml</value>?<!-- 這里是compass所需要的兩個關于數(shù)據(jù)項的配置文件 -->
????<value>classpath:mycompass.cpm.xml</value>
???</list>
??</property>
??<property name="configLocation">
???<value>classpath:mycompass.cfg.xml</value>?<!-- 這里是compass的系統(tǒng)配置文件的路徑 -->
??</property>
??<!--???????? <property name="compassSettings">
???<props>
???<prop key="compass.engine.connection">file://d:/target</prop>
???<prop key="compass.transaction.factory">org.compass.spring.transaction.SpringSyncTransactionFactory</prop>
???</props>
???</property>-->
??<property name="transactionManager">
???<ref local="transactionManager" />
??</property>
?</bean>
?<bean id="hibernateGpsDevice"
??class="org.compass.spring.device.hibernate.SpringHibernate3GpsDevice">
??<property name="name">
???<value>hibernateDevice</value>
??</property>
??<property name="sessionFactory">
???<ref local="sessionFactory" />
??</property>
?</bean>
?<bean id="compassGps" class="org.compass.gps.impl.SingleCompassGps"
??init-method="start" destroy-method="stop">
??<property name="compass">
???<ref bean="compass" />
??</property>
??<property name="gpsDevices">
???<list>
????<bean
?????class="org.compass.spring.device.SpringSyncTransactionGpsDeviceWrapper">
?????<property name="gpsDevice" ref="hibernateGpsDevice" />
????</bean>
???</list>
??</property>
?</bean>
?<!-- COMPASS END -->
</beans>
15.?注意上面的所以配置文件,根據(jù)我們上面的配置,都應當放到classpath的根路徑。
16.?建立工具類,用來進行spring引擎的初始化工作。
/**
?* <p>@(#) IOC.java 2006-2-1 0:08:23</p>
?* <p>Copyright (c) 2005-2006 ???????????????????</p>
?*/
package com.darkhe.sample.mycompass;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
?*
?*
?* @version 1.0 2006-2-1
?* @author darkhe
?*/
public class IOC {
?private static ApplicationContext context = null;
?private static boolean isInit = false;
?private IOC() {
??super();
?}
?private static void init() {
?
??if (isInit == false) {
???String[] xmlfilenames = { "applicationContext-hibernate.xml" };
???context = new ClassPathXmlApplicationContext(xmlfilenames);
???isInit = true;
??}
?}
?/**
? *?
? * @return
? */
?public static ApplicationContext getContext() {
??if (context == null || isInit == false) {
???init();
??}
??return context;
?}
?/**
? *
? * @param name
? * @return
? */
?public static Object getBean(String name) {
??return getContext().getBean(name);
?}
}
17.?建立索引程序,用來數(shù)據(jù)庫中的建立索引
/*
?* Copyright (c) 2005-2006
?* ChongQing Man-Month Technology Development Co. ,Ltd
?*
?* ---------------------------------------------------------------------------------
?* @(#) Inder.java, 2006-8-1 下午09:01:14
?* ---------------------------------------------------------------------------------
?*/
package com.darkhe.sample.mycompass;
import java.io.FileNotFoundException;
import org.compass.gps.CompassGps;
import org.springframework.context.ApplicationContext;
/**
?* @author darkhe
?*
?*/
public class Indexer {
?/**
? * @param args
? * @throws FileNotFoundException
? */
?public static void main(String[] args) throws FileNotFoundException {
???// 加裁自定義詞典
??DictionaryUtils.loadCustomDictionary();
??ApplicationContext context = IOC.getContext();
??// 得到spring環(huán)境中已經(jīng)配置和初始化好的compassGps對象
??CompassGps compassGps = (CompassGps) context.getBean("compassGps");
??// 調用index方法建立索引
??compassGps.index();
?}
}
18.?建立搜索程序,檢證compass的應用。
/*
?* Copyright (c) 2005-2006
?* ChongQing Man-Month Technology Development Co. ,Ltd
?*
?* ---------------------------------------------------------------------------------
?* @(#) Searcher.java, 2006-8-1 下午09:36:29
?* ---------------------------------------------------------------------------------
?*/
package com.darkhe.sample.mycompass;
import java.io.FileNotFoundException;
import org.compass.core.Compass;
import org.compass.core.CompassCallbackWithoutResult;
import org.compass.core.CompassException;
import org.compass.core.CompassHits;
import org.compass.core.CompassSession;
import org.compass.core.CompassTemplate;
import org.compass.core.Resource;
import org.springframework.context.ApplicationContext;
/**
?* @author darkhe
?*
?*/
public class Searcher {
?/**
? * @param args
? * @throws FileNotFoundException
? */
?public static void main(String[] args) throws FileNotFoundException {
??// 加裁自定義詞典
??DictionaryUtils.loadCustomDictionary();
??ApplicationContext context = IOC.getContext();
??Compass compass = (Compass) context.getBean("compass");
??CompassTemplate template = new CompassTemplate(compass);
??template.execute(new CompassCallbackWithoutResult() {
???protected void doInCompassWithoutResult(CompassSession session)
?????throws CompassException {
????CompassHits hits = session.find("大頭人");
????System.out.println("Found [" + hits.getLength()
??????+ "] hits for [大頭人] query");
????System.out
??????.println("======================================================");
????for (int i = 0; i < hits.getLength(); i++) {
?????print(hits, i);
????}
????hits.close();
???}
??});
?}
?public static void print(CompassHits hits, int hitNumber) {
??Object value = hits.data(hitNumber);
??Resource resource = hits.resource(hitNumber);
??System.out.println("ALIAS [" + resource.getAlias() + "]? SCORE ["
????+ hits.score(hitNumber) + "]");
??System.out.println(":::: " + value);
??System.out.println("");
?}
}
19.?工具類DictionaryUtils是用來管理我們自己采用的中文分詞算法的加載自定義詞典的。
/**
?* Copyright (c) 2005-2006 重慶人月科技發(fā)展有限公司
?*
?* ------------------------------------------------------------------------------
?* @(#) DictionaryUtils.java, 2006-8-2 下午04:55:22
?* ------------------------------------------------------------------------------
?*/
package com.darkhe.sample.mycompass;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import jeasy.analysis.MMAnalyzer;
/**
?*
?* @author darkhe
?* @version 1.0.0
?*/
public class DictionaryUtils {
?// 靜態(tài)變量
?private static boolean isInit = false;
?// 靜態(tài)初始化
?// 靜態(tài)方法
?public static void loadCustomDictionary() throws FileNotFoundException {
??if (isInit == false) {
???// 添加我們自己的詞典
???FileReader fr = new FileReader(new File("dict.txt"));
???MMAnalyzer.addDictionary(fr);
???
???//System.out.println("添加我們自己的詞典");
???isInit = true;
??}
?}
}
20.?執(zhí)行Indexer,再執(zhí)行Seracher后控制臺信息如下:
Found [1] hits for [大頭人] query
================================================
ALIAS [Article] SCORE [0.3988277]
:::: com.darkhe.sample.mycompass.Article@bla4e2
具體結果和你的數(shù)據(jù)表中的內容有別。
21.?這樣,我們便實現(xiàn)了如何利用compass構建我們自己的搜索引擎的一個簡單實現(xiàn)。
log4j.properties
- org
?? - compassframework
???? - sample
?????? - example
?????????? alias.cmd.xml
?????????? compass.cfg.xml
?????????? CompassExample.java
?????????? Phrase.cpm.xml
?????????? Phrase.java
下面說一下幾個重要的配置文件
?compass.cfg.xml
code
指定的target/index?是一個存儲目錄放索引文件的(這個類必須有個無參數(shù)的構造和id屬性)
?alias.cmd.xml
:
Phrase.java
java 代碼
-
package
?org.compassframework.sample.example; ??
-
??
-
public
?
class
?Phrase?{ ??
-
??
-
?
private
?String?author; ??
-
??
-
?
private
?String?text; ??
-
??
-
?
private
?Long?id; ??
-
??
-
?
public
?Phrase()?{ ??
-
??
-
?} ??
-
??
-
?
public
?String?getAuthor()?{ ??
-
?????
return
?author; ??
-
?} ??
-
??
-
?
public
?
void
?setAuthor(String?author)?{ ??
-
?????
this
.author?=?author; ??
-
?} ??
-
??
-
?
public
?String?getText()?{ ??
-
?????
return
?text; ??
-
?} ??
-
??
-
?
public
?
void
?setText(String?text)?{ ??
-
?????
this
.text?=?text; ??
-
?} ??
-
??
-
?
public
?Long?getId()?{ ??
-
?????
return
?id; ??
-
?} ??
-
??
-
?
public
?
void
?setId(Long?id)?{ ??
-
?????
this
.id?=?id; ??
-
?} ??
-
??
-
?
public
?String?toString()?{ ??
-
??
-
?????
return
?text; ??
-
?} ??
-
??
-
}? ??
Phrase.cpm.xml
?
xml 代碼
-
<!--sp-->xml?version="1.0"?>? ??
-
<!--CTYPE?compass-core-mapping?PUBLIC? ??</sp-->
-
"-//Compass/Compass?Core?Mapping?DTD?1.0//EN"? ??
-
"http://static.compassframework.org/dtd/compass-core-mapping-1.0.dtd"
>
? ??
-
<
compass-core-mapping
?
package
=
"org.compassframework.sample.example"
>
? ??
-
<
class
?
name
=
"Phrase"
?
alias
=
"${example.phrase}"
>
??
-
??
-
<
id
?
name
=
"id"
?
/>
??
-
??
-
<
property
?
name
=
"author"
>
??
-
??
-
<
meta-data
>
${example.author}
meta-data
>
??
-
??
-
property
>
??
-
??
-
<
property
?
name
=
"text"
>
??
-
??
-
<
meta-data
>
${example.text}
meta-data
>
??
-
??
-
property
>
??
-
??
-
class
>
??
-
??
-
compass-core-mapping
>
??
CompassExample.java
?
為了保證能打印出我們的測試,需要加入log4j.properties :
log4j.rootLogger=ERROR, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d %p %c - %m%n
log4j.logger.org.compassframework.sample.example=DEBUG
下面是打印出來的測試結果:
search() - Found 1 hits for "mule AND crazy"
print() - Phrase by Joe: I don't think it's nice you laughing...
search() - Found 0 hits for "Marisol OR Ramon"
下面闡述Compass的一些名詞:
1:Resource,Compass對Lucene的Document的抽象,與Alias聯(lián)系在一起。
2:Property,Compass對Lucene的Field的抽象。通過Compass Converter framework將不是String類型的對象轉換為可以索引的Property。
3:RSEM:Resource/Search Engine Mapping,資源搜索引擎影射。
4:Lucene采用IndexReader、Searcher、IndexWriter三個類完成索引搜索的功能。而Compass只有一個簡單的接口,能夠通過該接口實現(xiàn)所有的操作。
5:事務索引和集成:lucene是非事務性的。無法和事務型的系統(tǒng)進行結合。Compass提供兩種提交事務:read_committed 和 serializable。
6:快速更新:lucene中,執(zhí)行更新必須先刪除舊的Document,然后再新建一個Document。由于Compass支持事務索引,因此每個要保存的Resource都必須有一個唯一標識。這樣更新的效率會更高。
7: All 支持:在lucene中,沒有辦法對一個Document的所有的字段進行搜索,要對所有字段進行搜索,必須創(chuàng)建一個包含所有field的一個 "all"field。compass默認地建立一個"all"屬性,并且該"all"屬性充當默認的搜索Field,當然,"all"property 可以設置成enabled或disabled、重命名或者不充當默認的搜索Property,也可以排除all中的某些屬性。
8:索引分塊,
來源:http://bbs.xml.org.cn/blog/more.asp?name=lhwork&id=18505
作者: 地獄男爵
compass官方網(wǎng)站: http://www.compassframework.org/
Compass是一流的JAVA搜索框架,可以快速修飾你的應用,使其具備Searchable的能力。
在沒有Compass,單純用Lucene的環(huán)境里,一般做法是定期遍歷數(shù)據(jù)庫,編碼將里面的內容轉為索引。
而Compass通過與 Hibernate和 Spring的結合,簡單的為Domain Object提供了到Lucene引擎的映射,而且索引庫能夠隨Domain Object同步更新(Data Mirror)。
?
XSP文件的根元素為<page>,通常使用xsp名字空間(<xsp:page>)。
一個簡單的例子如:1: <?xml version="1.0"?>
2: <?cocoon-process type=”xsp”?>
3:
4: <xsp:page
5: language=”java”
6: xmlns:xsp=”http://apache.org/xsp”>
7:
8: <date>
9: <xsp:expr>new java.util.Date().toString()</xsp:expr>
10: </date>
11: </xsp:page>
2004年出版的Professional XML Development with Apache Tools: Xerces, Xalan, FOP, Cocoon, Axis, Xindice一書稱2行是必須的,但是我在Cocoon 2.1.9下測試發(fā)現(xiàn),其中的第2行聲明可以去掉。
下面看一個在XSP里定義一個函數(shù)的例子:
1: <?xml version="1.0"?>
2: <?cocoon-process type=”xsp”?>
3:
4: <xsp:page
5: language=”java”
6: xmlns:xsp=”http://apache.org/xsp”>
7:
8: <xsp:structure>
9: <xsp:include>java.util.Date</xsp:include>
10: </xsp:structure>
11:
12: <xsp:logic>
13: String getDate() {
14: Date d = new Date();
15: return d.toString();
16: }
17: </xsp:logic>
18:
19: <date>
20: <xsp:expr>getDate()</xsp:expr>
21: </date>
22: </xsp:page>
可以看到,定義函數(shù)的代碼被放在了<xsp:logic>元素里,另外使用<xsp:structure>和其子元素<xsp:include>元素可以導入Java的類。
完整的XSP元素列表如下:
<?cocoon-process?> This processing instruction (PI) tells Cocoon how to process this file. You may have multiple cocoon-process PIs because Cocoon can process an XSP page in two different ways. It can process the document as an XSP file, causing the language code to be executed. To indicate this style of processing, specify “xsp” as the value of the type pseudo-attribute. Cocoon can also use an XSL stylesheet to transform the document. This can occur either before or after the XSP processing. The processing order is determined by the order in which the PIs appear in the document. To use a stylesheet with an XSP document, specify “xslt” as the value of the type pseudo-attribute. If you use a stylesheet with the document, you need to supply an XML stylesheet processing instruction that tells where to find the stylesheet. (See the next item.)
<?xml-stylesheet?> This PI is defined by the W3C’s Associating Style Sheets with XML Documents recommendation. Associating a stylesheet is easy; you supply two pseudo-attributes. The href pseudo-attribute contains the URI for the stylesheet, and the type pseudo-attribute contains the MIME type of the stylesheet, which should be “text/xsl” for XSLT stylesheets.
<xsp:page> The root element of an XSP page is <xsp:page>. It takes a language attribute that allows you to specify the programming language being used in the XSP. You’ll probably also define some namespace prefixes on this element. The minimum would be for you to define the xsp prefix. The <xsp:page> must contain at least one user-defined element that’s used as the root element of the XSP result.
<xsp:structure> This element is a container for <xsp:include> elements.
<xsp:include> XSP uses the <xsp:include> element to import type definitions that are needed by the rest of the XSP. In Java, these are specified either as fully qualified classnames or in wildcarded package style, like java.util.*.
<xsp:logic> The implementation of the logic of an XSP should be the content of the <xsp:logic> element. For Java-based XSPs, this includes member fields and methods.
<xsp:expr> An <xsp:expr> element invokes logic in the <xsp:logic> to return a string valued expression. In Java, this is through method calls, field accesses, or string literals. Java string literals that appear as the content of an <xsp:expr> tag must be inside double quotes (”").
<xsp:element> This element allows you to dynamically create an element in the output XML. The <xsp:element> element takes a name attribute whose value is the name of the element to be created. You can nest these elements to create element subtrees dynamically. You can also insert literal XML elements and character data as part of the content of this element.
<xsp:attribute> The <xsp:attribute> element should appear as the child of either an <xsp:element> element or a literal XML element. It allows you to dynamically create an attribute by supplying a name attribute for the name of the new attribute. The value of the new attribute is the content of the <xsp:attribute> element.
<xsp:comment> To create a comment in the XSP output, use the <xsp:comment> element and make the content of the element the text of your comment.
<xsp:pi> The <xsp:pi> element allows you to create processing instructions. You supply a target attribute that defines the PI target name. If you wish to create pseudo-attributes, you do so via <xsp:expr> elements in the content of the <xsp:pi> element. So, to create a PI that looks like <?xml-stylesheet href=”sheet.xsl” type=”text/xsl”?>, your <xsp:pi> element would look like this:
<xsp:pi target="xml-stylesheet"> <xsp:expr>"href=\"sheet.xsl\" type=\"text/xsl\""</xsp:expr> </xsp:pi>
通過使用 xsp:element,還可以動態(tài)地創(chuàng)建元素,如:
<xsp:element>
<xsp:param name="name"><xsp:expr>"myElementName"</xsp:expr></xsp:param>
Element content
</xsp:element>
這個示例顯示了用動態(tài)生成名稱創(chuàng)建元素涉及使用 xsp:element 和 xsp:param 元素。xsp:param定義了一個參數(shù),在本例中是元素的名稱,其值是一個用于計算元素名稱的表達式。
上面的代碼將生成 XML 輸出
<myElementName>Element content</myElementName>
用這種方式創(chuàng)建的元素還可以與一個特定的名稱空間和前綴關聯(lián),如下例所示。請注意:這兩個名稱空間和前綴參數(shù)都是必需的;否則將產(chǎn)生錯誤。
<xsp:element prefix="my" uri="http://www.examples.org">
<xsp:param name="name"><xsp:expr>"myElementName"</xsp:expr></xsp:param>
Element content
</xsp:element>
這個示例生成了以下 XML 輸出:
<my:myElementName xmlns:my="http://www.examples.org">Element content</my:myElementName>
如同元素一樣,可以在 XSP 頁面中動態(tài)創(chuàng)建屬性。xsp:attribute 元素的工作原理類似于 xsp:element,它允許動態(tài)創(chuàng)建屬性的名稱及其值:
<xsp:element>
<xsp:param name="name"><xsp:expr>"myElementName"</xsp:expr></xsp:param>
<xsp:attribute name="myAttribute">myAttributeValue</xsp:attribute>
Element content
</xsp:element>
這個屬性的名稱定義在 name 屬性內,盡管是用與 xsp:element 類似的方法定義的,但它還能通過使用 xsp:param 子元素來定義。屬性值被指定成元素內容。這可以是一個簡單文本值或更有效地由 xsp:expr 元素生成。
而 xsp:attribute 標記不必與 xsp:element 結合使用。它可以被放置在任何用戶元素內,而且可以用相同的方法添加屬性。例如,可以通過使用調用定義在 XSP 頁面別處的方法的表達式來動態(tài)創(chuàng)建 image 元素的 URL。
<image>
<xsp:attribute name="href"><xsp:expr>calculateImageURL()</xsp:expr></xsp:attribute>
</image>
如果生成的屬性與特定的名稱空間關聯(lián),那么這可以通過使用附加的 prefix 和 uri 屬性或 xsp:param 元素來表示,它類似于用于 xsp:element 的方法。同樣,如果只定義了其中的一個,則是一個錯誤。
創(chuàng)建注釋和處理指令
xsp:comment 和 xsp:pi 元素用于創(chuàng)建注釋和處理指令。
創(chuàng)建注釋十分簡單。任何作為 xsp:comment 元素的子元素而提供的文本都變成了 XML 注釋:
<xsp:comment>This is a comment</xsp:comment>
然后這個注釋變成:
<!-- This is a comment -->
創(chuàng)建處理指令類似于創(chuàng)建動態(tài)元素或屬性。xsp:pi 元素應該有一個標識處理指令目標的嵌套參數(shù)。照例對 xsp:pi 元素的剩余內容求值。這里是一個簡單示例:
<xsp:pi target="myApplication">
<xsp:expr>"param1=value, param2=value, generatorTimestamp=" +
System.currentTimeMillis()</xsp:expr>
</xsp:pi>
輸出如下:
<?myApplication param1=value, param2=value, generatorTimestamp=1017407796870?>
還可以通過在 xsp:param 元素內創(chuàng)建處理指令的目標來自動生成它,如同以下示例演示的那樣:
<xsp:pi>
<xsp:param name="target"><xsp:expr>"myApplication"</xsp:expr></xsp:param>
<xsp:expr>"param1=value, param2=value, generatorTimestamp=" +
System.currentTimeMillis()</xsp:expr>
</xsp:pi>
這個問題出現(xiàn)在要刪除關系的一頭時。如,要刪除一個已經(jīng)和Student有關系的Teacher。當tx.commit();
??? 時才會拋出這個異常。這時一個在關系另一頭的Student對象中的Set或是List中把這個Teacher對象顯示的remove掉,
??? 再session.delete(這個teacher);。這是為了防止在Student端有cascade時把這個Teacher對象再存回DB。
??? 所以,這個異常的只有在Student的關系定義中有cascade="...",而且沒有像上面說的顯示的解除關系時才會出現(xiàn)。
??? 所以防止出現(xiàn)這個異常的方法就是:1,在Student端不用cascade;2,或是用cascade的話,就顯示的刪除對像中的關系。
??? 3,在Teacher端要用cascade
?。?、net.sf.hibernate.HibernateException: identifier of an instance of my.MyObject altered from N to N
這個異常其時不是多對多中常遇到的,但是這個異常的提示不make sense,所以提一下,
??? 是因為id的java對象中的type和hbm文件中定義的不一樣,如:java中用long,而hbm中用type="integer",
??? 并且generator用的是identity時就會出現(xiàn)
create table trole (
? role_id int not null auto_increment,
? name varchar(16) not null default ′′,?
? primary key? (role_id)
) type=innodb;
create table tgroup_role (
? group_id int not null,
? role_id int not null,
? primary key(group_id, role_id),
? index (group_id),
? foreign key (group_id) references tgroup(group_id),
? index (role_id),
? foreign key (role_id) references trole(role_id)
) type=innodb;
Group 類:
package ivan.hibernate.many2many;
public class Group {
? ?private int id;
? ?private String name;
? ?private Set roles = new HashSet();
?? ...
}
Group.hbm.xml:
<hibernate-mapping>
??? <class name="ivan.hibernate.many2many.Group" table="tgroup">
??????? <id name="id" column="group_id" unsaved-value="0">
??????????? <generator class="increment"/>
??????? </id>
??????? <property name="name" type="string"/>??????
??????? <set name="roles"
???????????? table="tgroup_role"
???????????? cascade="save-update">????????????
???????????? <key column="group_id"/>
???????????? <many-to-many class="ivan.hibernate.many2many.Role"
?????????????????????????? column="role_id"/>
?????? </set>
??? </class>
</hibernate-mapping>
Role 類:
package ivan.hibernate.many2many;
public class Role {
?? private int id;
? ?private String name;
? ?private Set groups = new HashSet();
?? ...
}
Role.hbm.xml:
<hibernate-mapping>
??? <class name="ivan.hibernate.many2many.Role" table="trole">
??????? <id name="id" column="role_id" unsaved-value="0">
??????????? <generator class="increment"/>
??????? </id>
??????? <property name="name" type="string"/>??????
??????? <set name="groups"
???????????? table="tgroup_role"
????????????
inverse="true"
???????????? cascade="save-update">????????????
???????????? <key column="role_id"/>
???????????? <many-to-many class="ivan.hibernate.many2many.Group"
?????????????????????????? column="group_id"/>
??</set>
??? </class>
</hibernate-mapping>
hibernate.cfg.xml 同前面的例子差不多。
public class Test {
?
?public static void main(String[] args) throws HibernateException {
????
??Role role1 = new Role();?
??role1.setName("Role1");
??Role role2 = new Role();
??role2.setName("Role2");
??Role role3 = new Role();
??role3.setName("Role3");
??Group group1 = new Group();
??group1.setName("group1");
??Group group2 = new Group();
??group2.setName("group2");
??Group group3 = new Group();
??group3.setName("group3");
??group1.getRoles().add(role1);
??group1.getRoles().add(role2);
??group2.getRoles().add(role2);
??group2.getRoles().add(role3);
??group3.getRoles().add(role1);
??group3.getRoles().add(role3);
??role1.getGroups().add(group1);
??role1.getGroups().add(group3);
??role2.getGroups().add(group1);
??role2.getGroups().add(group2);
??role3.getGroups().add(group2);
??role3.getGroups().add(group3);
?
??SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
??Session session = sessionFactory.openSession();
??Transaction tx= session.beginTransaction();
??session.save(role1);
??session.save(role2);
??session.save(role3);
??session.save(group1);
??session.save(group2);
??session.save(group3);
??tx.commit();
??session.close();
??sessionFactory.close();
?}
}
<xsp:page language="java"
? xmlns:xsp="? xmlns:xsp-request="? xmlns:xscript="? xmlns:soap="?
? <page>
????? <content>
????? <xsp:logic>
?????? String cFCType= request.getParameter("cFCType");
???????String cPFrom= request.getParameter("cPFrom");
?<para>
????????<xsp:expr>iStartYear</xsp:expr>
?</para>
?<para>
?? <soap:call url="???? <ns1:getcurrforecast xmlns:ns1="urn:www.gpe.com:forecast:forecast">
???? <soap:enc/>
???? ?<cFCType xsi:type="xsd:string" xmlns:xsi=">
???? </ns1:getcurrforecast>
?? </soap:call>
?</para>
????? </xsp:logic>
????? </content>
? </page>
?
</xsp:page>
xml2html 代碼
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
???? xmlns:xsl="???? xmlns:sql="<xsl:output method="html"/>
<xsl:template match="/">
<xsl:variable name="s" select="number(//fp_id_12)"/>
<table border="0" width="100%" height="50">
<tr>
<td width="30%" align="left">
<img border="0" src="</td>
<td width="40%" align="center" style="font-size: 30pt"><b><u>Forecast Report</u></b></td>
<td width="30%" align="right" style="font-size: 14pt">
<SCRIPT>
document.write(Date());
</SCRIPT>
</td>
</tr>
</table>
<table border="0" bgcolor="#66CCFF" width="100%" style="border: 1px #66CCFF" cellspacing="1" cellpadding="1">
?<tr bgcolor="#66CCFF">
?? <th style="font-size: 9pt"><nobr>Part No</nobr></th>
?? <th style="font-size: 9pt"><nobr>Description</nobr></th>
?</tr>
?<xsl:for-each select="http://Item">
??<tr bgcolor="#FFFFFF">
??<td style="font-size: 9pt"><nobr><xsl:value-of select="product_code"/></nobr></td>
??<td style="font-size: 9pt"><nobr><xsl:value-of select="description"/></nobr></td>
?</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
xml2xls 代碼
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="????????????????????????????? xmlns:sql="???????????????????????????? xmlns:gmr="? <xsl:output method="xml" />
? <xsl:template match="/">
?<gmr:Workbook xmlns:gmr="????? <gmr:SheetNameIndex>
??????? <gmr:SheetName>Sheet 1</gmr:SheetName>
????? </gmr:SheetNameIndex>
????? <gmr:Sheets>
??????? <gmr:Sheet>
????????? <gmr:Name>Sheet 1</gmr:Name>
????????? <gmr:Styles>
??????????? <gmr:StyleRegion startRow="0" endRow="0" startCol="0" endCol="99">
?????????????? <gmr:Style HAlign="8" VAlign="4" WrapText="0" Orient="1"
???????????????????????? Shade="0" Indent="0" Locked="1" Hidden="0"
???????????????????????? Fore="0:0:0" Back="FFFF:FFFF:FFFF"
???????????????????????? PatternColor="0:0:0" Format="General">
??????????????? <gmr:Font Unit="10" Bold="1" Italic="0" Underline="0" StrikeThrough="0">
????????????????? Helvetica
??????????????? </gmr:Font>
????????????? </gmr:Style>
??????????? </gmr:StyleRegion>
????????? </gmr:Styles>
????????? <gmr:Cells>
?????? <xsl:call-template name="headerrow"/>
??????????? <xsl:apply-templates select="http://Item"/>
????????? </gmr:Cells>
??????? </gmr:Sheet>
????? </gmr:Sheets>
??? </gmr:Workbook>
</xsl:template>
<xsl:template name="headerrow">
??? ??<gmr:Cell Row="0" Col="0" ValueType="60">Part No</gmr:Cell>
??<gmr:Cell Row="0" Col="1" ValueType="60">Description</gmr:Cell>
</xsl:template>
<xsl:template match="Item">
??? <xsl:variable name="row" select="position()"/>
??? <gmr:Cell Row="{$row}" Col="0" ValueType="60">
????? <xsl:value-of select="product_code"/>
??? </gmr:Cell>
??? <gmr:Cell Row="{$row}" Col="1" ValueType="60">
????? <xsl:value-of select="description"/>
??? </gmr:Cell>
</xsl:template>
</xsl:stylesheet>