这是适用于稍微改变的 xml 的 XSLT
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:TEI="urn:tei"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="msxsl xhtml TEI"
>
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match="commentary">
<p>
<xsl:apply-templates />
</p>
</xsl:template>
<!-- remove namepace, keep name -->
<xsl:template match="xhtml:*">
<xsl:element name="{local-name()}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
<!-- surpress nodes in a namespace -->
<xsl:template match="TEI:*">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
输入xml:
<?xml version="1.0" encoding="utf-8" ?>
<root xmlns:TEI="urn:tei" xmlns:xhtml="http://www.w3.org/1999/xhtml" >
<commentary>
<TEI:persName>King Henry iv</TEI:persName> was an <xhtml:b>important</xhtml:b> person.
</commentary>
</root>
这是VS2010根据上面的xml为我生成的schema
<xs:schema xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:TEI="urn:tei" attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="urn:tei" />
<xs:import namespace="http://www.w3.org/1999/xhtml" />
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="commentary">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element ref="TEI:persName" />
<xs:element ref="xhtml:b" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
TEI 架构
<xs:schema xmlns:tns="urn:tei" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:tei" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="persName" type="xs:string" />
</xs:schema>