XMLSpy编辑XSD,DTD,XML和XSLT文件非常方便,altova公司还提供了Home Edition免费版提供下载。
首先定义一个描述Component的XML Schema文件
xml version="1.0" encoding="UTF-8" ?>
-- edited with XMLSpy v2005 rel. 3 U (http://www.altova.com) by ibm (ibm) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:col="http://www.novacolimas.com/colimas/namespace"
targetNamespace="http://www.novacolimas.com/colimas/namespace" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="ComponentsBasicInfo">
<xs:annotation>
<xs:documentation>Title: cbi.xsd
Subject: the component basic information.
Publisher: Nova Corporation, Colimas.
Format: text/xml
Creator: Zhao Lei
Date.Created: 2005-04-23
Language: en-US
Description:
Change Log:
Version Date Modifier Description
01.00 2005/04/25 Zhao Lei Initial release.
xs:documentation>
xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="ComponentBasicInfo" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="SerialNo">
<xs:annotation>
<xs:documentation>Component SerialNo, 27 characters with a-z or A-Z or 0-9xs:documentation>
xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[a-zA-Z0-9]{27}" />
xs:restriction>
xs:simpleType>
xs:element>
<xs:element name="Name" type="xs:string">
<xs:annotation>
<xs:documentation>Component Namexs:documentation>
xs:annotation>
xs:element>
<xs:element name="Alias" type="xs:string">
<xs:annotation>
<xs:documentation>Component Aliasxs:documentation>
xs:annotation>
xs:element>
<xs:element name="Version" default="1.0">
<xs:annotation>
<xs:documentation>Component Versionxs:documentation>
xs:annotation>
xs:element>
<xs:element name="DevelopmentLanguage" type="xs:string">
<xs:annotation>
<xs:documentation>Component Development Languagexs:documentation>
xs:annotation>
xs:element>
<xs:element name="DevelopmentPlatform" type="xs:string" />
<xs:element name="Authors" type="xs:string" />
<xs:element name="Status" default="Unconfirmed">
<xs:annotation>
<xs:documentation>the status of component: Unconfirmed | Confirmed | Deletedxs:documentation>
xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="Unconfirmed|Confirmed|Deleted" />
xs:restriction>
xs:simpleType>
xs:element>
<xs:element name="ConfirmDate" type="xs:dateTime" />
<xs:element name="ConfirmBy" type="xs:string" />
<xs:element name="CreateDate" type="xs:dateTime" />
<xs:element name="CreateBy" type="xs:string" />
<xs:element name="LastChangeDate" type="xs:dateTime" />
<xs:element name="LastChangeBy" type="xs:string" />
<xs:element name="BrowseTimes" type="xs:integer" default="0" />
<xs:element name="IsPublic" type="xs:boolean" default="true">
<xs:annotation>
<xs:documentation>whether the component is publicxs:documentation>
xs:annotation>
xs:element>
<xs:element name="DevelopmentEnvironment" type="xs:string" />
<xs:element name="FunctionDescription" type="xs:string" />
<xs:element name="Developers">
<xs:simpleType>
<xs:restriction base="xs:string" />
xs:simpleType>
xs:element>
<xs:element name="Admins">
<xs:simpleType>
<xs:restriction base="xs:string" />
xs:simpleType>
xs:element>
xs:sequence>
xs:complexType>
xs:element>
xs:sequence>
xs:complexType>
xs:element>
xs:schema>
用XMLSpy编辑一个cbi.xsd的xml文件:cbidebug.xml
xml version="1.0" encoding="UTF-16"?>
xml-stylesheet type="text/xsl" href="component.xslt"?>
<ComponentsBasicInfo xmlns="http://www.novacolimas.com/colimas/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.novacolimas.com/colimas/namespace
C:\DOCUME~1\Administrator\MYDOCU~1\NovaPlan\Colimas\ID\XSD\cbi.xsd">
<ComponentBasicInfo>
<SerialNo>aaaaaaaaaaaaaaaaaaaaaaaaaaaSerialNo>
<Name>Mactintosh组件Name>
<Alias>Mactintosh componentAlias>
<Version>1.0Version>
<DevelopmentLanguage>JavaDevelopmentLanguage>
<DevelopmentPlatform>LinuxDevelopmentPlatform>
<Authors>磊 赵, 福锦 黄Authors>
<Status>UnconfirmedStatus>
<ConfirmDate>2001-12-17T09:30:47.0ZConfirmDate>
<ConfirmBy>StringConfirmBy>
<CreateDate>2001-12-17T09:30:47.0ZCreateDate>
<CreateBy>StringCreateBy>
<LastChangeDate>2001-12-17T09:30:47.0ZLastChangeDate>
<LastChangeBy>StringLastChangeBy>
<BrowseTimes>123BrowseTimes>
<IsPublic>trueIsPublic>
<DevelopmentEnvironment>WSAD,XML, Websphere, DB2, WebSphere MQ, AIX.CPU is IntelDevelopmentEnvironment>
<FunctionDescription>Component Function Description.FunctionDescription>
<Developers>Lei Zhao, Herry ChowDevelopers>
<Admins>Lei ZhaoAdmins>
ComponentBasicInfo>
ComponentsBasicInfo>
接着定义XSLT文件:component.xslt
其中<xsl:variable name="componentinfo.cominfo" select="'Component Information'"/>
的select值可以更换为其他语言。
xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:col="http://www.novacolimas.com/colimas/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:variable name="componentinfo.cominfo" select="'Component Information'"/>
<xsl:variable name="template.edit" select="'Edit!'"/>
<xsl:variable name="template.down" select="'Download'"/>
<xsl:variable name="template.confirm" select="'Confirm!'"/>
<xsl:variable name="template.del" select="'Delete!'"/>
<xsl:variable name="componentinfo.fundesc" select="'Function Description'"/>
<xsl:variable name="componentinfo.deven" selectfont-size: 10pt; color: blue; font-