Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
转换xml+;xsd到xhtml_Xml_Xhtml_Xsd - Fatal编程技术网

转换xml+;xsd到xhtml

转换xml+;xsd到xhtml,xml,xhtml,xsd,Xml,Xhtml,Xsd,我正在尝试将带有xsd模式的xml转换为xhtml 因此,在我的xml文件中,我有如下内容: <shf:BookShelf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="BookShelf BookShelf.xsd" xmlns:shf="BookShelf" xmlns:bk="BookType" xmlns:cmn="C

我正在尝试将带有xsd模式的xml转换为xhtml

因此,在我的xml文件中,我有如下内容:

<shf:BookShelf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="BookShelf BookShelf.xsd"
        xmlns:shf="BookShelf"
        xmlns:bk="BookType"
        xmlns:cmn="CommonType">
   <shf:Book Category="Physics">
      <bk:Name></bk:Name>
      <bk:Author>
         <cmn:FirstName></cmn:FirstName>
         <cmn:FamilyName></cmn:FamilyName>
      </bk:Author>
      <bk:Pages></bk:Pages>
      <bk:Language></bk:Language>
      <cmn:Source></cmn:Source>
   </shf:Book>
...
</shf:BookShelf>

...
我知道将xml转换为xhtml要容易得多,但现在我有了
,如何在xsl中引用这个条目?这是我在xsl中所做的,但它不起作用:

<xsl:for-each select="BookShelf/Book">
<tr>
  <td><xsl:value-of select="Name"/></td>     
</tr>
</xsl:for-each>

您可以使用:

<xsl:for-each select="shf:BookShelf/shf:Book">
    <tr>
         <td><xsl:value-of select="bk:Name"/></td>     
    </tr>
</xsl:for-each>

并在
中声明名称空间:

。。。
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" 
    xmlns:shf="BookShelf" xmlns:bk="BookType" xmlns:cmn="CommonType"> ...