我想知道如何從我的xml文檔中獲取不同的命名空間以用於轉換爲xsl-fo。我有如下:從xml文檔獲取不同的命名空間
XML:
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="style.xsl" ?>
<ovgs xmlns:ncb="http://www.namcobandai.com/NS" xmlns:sqe="http://www.squareenix.com/NS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="main.xsd">
<upcoming>
<ncb:game>
<ncb:cover>nnk_cover.jpg</ncb:cover>
<ncb:title>Ni no Kuni: Wrath of the White Witch</ncb:title>
<ncb:publisher>Namco Bandai Games America</ncb:publisher>
<ncb:developer>Level 5</ncb:developer>
<ncb:genre>Role-Playing</ncb:genre>
<ncb:releaseDate>
<ncb:yyyy>2013</ncb:yyyy>
<ncb:mm>01</ncb:mm>
<ncb:dd>22</ncb:dd>
</ncb:releaseDate>
<ncb:esrbRating>E10+</ncb:esrbRating>
<ncb:platforms>
<ncb:platform>PS3</ncb:platform>
</ncb:platforms>
</ncb:game>
<sqe:game>
<sqe:cover>tr_cover.jpg</sqe:cover>
<sqe:title>Tomb Raider</sqe:title>
<sqe:publisher>Square Enix</sqe:publisher>
<sqe:developer>Crystal Dynamics</sqe:developer>
<sqe:genre>Action</sqe:genre>
<sqe:releaseDate>
<sqe:yyyy>2013</sqe:yyyy>
<sqe:mm>03</sqe:mm>
<sqe:dd>05</sqe:dd>
</sqe:releaseDate>
<sqe:esrbRating>M</sqe:esrbRating>
<sqe:platforms>
<sqe:platform>X360</sqe:platform>
<sqe:platform>PC</sqe:platform>
<sqe:platform>PS3</sqe:platform>
</sqe:platforms>
</sqe:game>
<sqe:game>
<sqe:cover>hma_cover.jpg</sqe:cover>
<sqe:title>Hitman: Absolution</sqe:title>
<sqe:publisher>Square Enix</sqe:publisher>
<sqe:developer>Io Interactive</sqe:developer>
<sqe:genre>Action</sqe:genre>
<sqe:releaseDate>
<sqe:yyyy>2012</sqe:yyyy>
<sqe:mm>11</sqe:mm>
<sqe:dd>20</sqe:dd>
</sqe:releaseDate>
<sqe:esrbRating>M</sqe:esrbRating>
<sqe:platforms>
<sqe:platform>X360</sqe:platform>
<sqe:platform>PC</sqe:platform>
<sqe:platform>PS3</sqe:platform>
</sqe:platforms>
</sqe:game>
</upcoming>
我想是對將採取的信息,並將其轉換成一個XSL-FO文件的XSLT文件的代碼。基本上我正在努力的是如何參考節點。我有什麼至今:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<fo:root>
<!-- overall layout -->
<fo:layout-master-set>
<fo:simple-page-master master-name="coverPage">
<fo:region-body/>
<fo:region-before extent="1in" />
<fo:region-after extent="1in" />
<fo:region-start extent="1in" />
<fo:region-end extent="1in" />
</fo:simple-page-master>
<fo:simple-page-master master-name="contentPage">
<fo:region-body/>
<fo:region-before extent="1in" background-color="#0000FF" />
<fo:region-after extent="1in" background-color="#0000FF" />
<fo:region-start/>
<fo:region-end/>
</fo:simple-page-master>
</fo:layout-master-set>
<!-- page content -->
<fo:page-sequence master-reference="coverPage">
<fo:flow flow-name="xsl-region-body">
<fo:block margin-top="2.5in" text-align="center"><fo:external-graphic content-height="scale-to-fit" height="2.5in" src="ovgsLogo.jpg" /></fo:block>
<fo:block font-weight="bold" text-align="center">Greetings all yee gamers!</fo:block>
</fo:flow>
</fo:page-sequence>
<xsl:for-each select="../upcoming/ncb:game">
<fo:page-sequence master-reference="contentPage">
<fo:static-content flow-name="xsl-region-before">
<fo:block margin-top="0.3in" text-align="center">OVGS Upcoming Games</fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-after">
<fo:block margin-top="0.3in" text-align="center">Page <fo:page-number /></fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block font-size="24pt" font-weight="bold" text-align="center" margin-top="2.5in" color="#FF0000"><xsl:value-of select="ncb:title" /></fo:block>
<fo:block text-align="center" margin-top="0.2in"><fo:external-graphic content-height="scale-to-fit" height="3in"><xsl:attribute name="src">url('<xsl:value-of select="ncb:cover" />')</xsl:attribute></fo:external-graphic></fo:block>
<fo:block font-weight="bold" text-align="center" margin-top="0.3in">Published by <xsl:value-of select="ncb:publisher" /></fo:block>
<fo:block font-weight="bold" text-align="center">Developed by <xsl:value-of select="ncb:developer" /></fo:block>
<fo:block font-weight="bold" text-align="center"><xsl:value-of select="ncb:genre" /></fo:block>
<fo:block font-weight="bold" text-align="center">Released on <xsl:value-of select="ncb:releaseDate/ncb:dd" />/<xsl:value-of select="ncb:releaseDate/ncb:mm" />/<xsl:value-of select="ncb:releaseDate/ncb:yyyy" /></fo:block>
<fo:block font-weight="bold" text-align="center">
Available on <xsl:value-of select="ncb:platforms/ncb:platform[1]" /><xsl:for-each select="ncb:platforms/ncb:platform">
<xsl:if test="position() != last() and position() != 1">, <xsl:value-of select="." /></xsl:if></xsl:for-each> and <xsl:value-of select="ncb:platforms/ncb:platform[last()]" />
</fo:block>
<fo:block text-align="center" background-color="#9900FF" margin-top="0.3in" margin-left="1in" margin-right="1in"><xsl:value-of select="ncb:esrbRating" /></fo:block>
</fo:flow>
</fo:page-sequence>
</xsl:for-each>
<xsl:for-each select="ovgs/upcoming/sqe:game">
<fo:page-sequence master-reference="contentPage">
<fo:static-content flow-name="xsl-region-before">
<fo:block margin-top="0.3in" text-align="center">OVGS Upcoming Games</fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-after">
<fo:block margin-top="0.3in" text-align="center">Page <fo:page-number /></fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block font-size="24pt" font-weight="bold" text-align="center" margin-top="2.5in" color="#FF0000"><xsl:value-of select="sqe:title" /></fo:block>
<fo:block text-align="center" margin-top="0.2in"><fo:external-graphic content-height="scale-to-fit" height="3in"><xsl:attribute name="src">url('<xsl:value-of select="sqe:cover" />')</xsl:attribute></fo:external-graphic></fo:block>
<fo:block font-weight="bold" text-align="center" margin-top="0.3in">Published by <xsl:value-of select="sqe:publisher" /></fo:block>
<fo:block font-weight="bold" text-align="center">Developed by <xsl:value-of select="sqe:developer" /></fo:block>
<fo:block font-weight="bold" text-align="center"><xsl:value-of select="sqe:genre" /></fo:block>
<fo:block font-weight="bold" text-align="center">Released on <xsl:value-of select="sqe:releaseDate/sqe:dd" />/<xsl:value-of select="sqe:releaseDate/sqe:mm" />/<xsl:value-of select="sqe:releaseDate/sqe:yyyy" /></fo:block>
<fo:block font-weight="bold" text-align="center">
Available on <xsl:value-of select="sqe:platforms/sqe:platform[1]" /><xsl:for-each select="sqe:platforms/sqe:platform">
<xsl:if test="position() != last() and position() != 1">, <xsl:value-of select="." /></xsl:if></xsl:for-each> and <xsl:value-of select="sqe:platforms/sqe:platform[last()]" />
</fo:block>
<fo:block text-align="center" background-color="#9900FF" margin-top="0.3in" margin-left="1in" margin-right="1in"><xsl:value-of select="sqe:esrbRating" /></fo:block>
</fo:flow>
</fo:page-sequence>
</xsl:for-each>
</fo:root>
</xsl:template>
看來你有空「育碧:標題」這就是爲什麼你沒有得到任何輸出元素。 –
您能向我們展示比40個字符更多的嘗試嗎? – JLRishe
現在好了嗎? – wizzkid