我感到非常困难,我知道有人可能会提供帮助,但我不确定如何提问,所以这里有希望。
需要最终结果:使用xslt的xml中的CSV文件 - 对于文件中的每个图像
"案件编号"," surename"," \ 00000000 \ 231.tif"
这是我所拥有的,你可以看到我没有得到非常接近。我得到了案例编号和确定的名称以及图像文件编号,但不能让它们按每个图像分开。
我的xml文件:
<?xml version="1.0" encoding="Windows-1252" ?>
<PFDM_DATAGRP>
<DGNUMBER>0001</DGNUMBER>
<DGCOMPNAME>Bbbb</DGCOMPNAME>
<DGCOMPID>0331</DGCOMPID>
<PROJECT PROJID="1">
<NAME>Microfiche</NAME>
<DOCINDEXFIELDS>
<DOCINDEXFIELD>
<NAME>CASE NUMBER</NAME>
<TYPE>TEXT</TYPE>
<FORMAT></FORMAT>
<REQUIRED>0</REQUIRED>
</DOCINDEXFIELD>
<DOCINDEXFIELD>
<NAME>SURNAME</NAME>
<TYPE>TEXT</TYPE>
<FORMAT></FORMAT>
<REQUIRED>0</REQUIRED>
</DOCINDEXFIELD>
</DOCINDEXFIELDS>
<DOCUMENTS>
<DOCUMENT DOCID="12">
<DOCINDEXFIELD>
<NAME>CASE NUMBER</NAME>
<VALUE>9264</VALUE>
</DOCINDEXFIELD>
<DOCINDEXFIELD>
<NAME>SURNAME</NAME>
<VALUE>VI</VALUE>
</DOCINDEXFIELD>
<DUPEID>0</DUPEID>
<OBJECT>
<OBJTYPE>0</OBJTYPE>
<PAGES>7</PAGES>
<FILE1>\00000000\231.tif</FILE1>
<FILE2>\00000000\232.tif</FILE2>
<FILE3>\00000000\233.tif</FILE3>
<FILE4>\00000000\234.tif</FILE4>
<FILE5>\00000000\235.tif</FILE5>
<FILE6>\00000000\236.tif</FILE6>
<FILE7>\00000000\237.tif</FILE7>
</OBJECT>
</DOCUMENT>
<DOCUMENT DOCID="13">
<DOCINDEXFIELD>
<NAME>CASE NUMBER</NAME>
<VALUE>9262</VALUE>
</DOCINDEXFIELD>
<DOCINDEXFIELD>
<NAME>SURNAME</NAME>
<VALUE>HA</VALUE>
</DOCINDEXFIELD>
<DUPEID>0</DUPEID>
<OBJECT>
<OBJTYPE>0</OBJTYPE>
<PAGES>47</PAGES>
<FILE1>\00000000\238.tif</FILE1>
<FILE2>\00000000\239.tif</FILE2>
<FILE3>\00000000\240.tif</FILE3>
<FILE4>\00000000\241.tif</FILE4>
<FILE5>\00000000\242.tif</FILE5>
<FILE6>\00000000\243.tif</FILE6>
<FILE7>\00000000\244.tif</FILE7>
<FILE8>\00000000\245.tif</FILE8>
<FILE9>\00000000\246.tif</FILE9>
<FILE10>\00000000\247.tif</FILE10>
<FILE11>\00000000\248.tif</FILE11>
<FILE12>\00000000\249.tif</FILE12>
<FILE13>\00000000\250.tif</FILE13>
<FILE14>\00000000\251.tif</FILE14>
<FILE15>\00000000\252.tif</FILE15>
<FILE16>\00000000\253.tif</FILE16>
<FILE17>\00000000\254.tif</FILE17>
<FILE18>\00000000\255.tif</FILE18>
<FILE19>\00000000\256.tif</FILE19>
</OBJECT>
</DOCUMENT>
<DOCUMENT DOCID="14">
<DOCINDEXFIELD>
<NAME>CASE NUMBER</NAME>
<VALUE>9260</VALUE>
</DOCINDEXFIELD>
<DOCINDEXFIELD>
<NAME>SURNAME</NAME>
<VALUE>HA</VALUE>
</DOCINDEXFIELD>
<DUPEID>0</DUPEID>
<OBJECT>
<OBJTYPE>0</OBJTYPE>
<PAGES>55</PAGES>
<FILE1>\00000000\306.tif</FILE1>
<FILE2>\00000000\307.tif</FILE2>
<FILE3>\00000000\308.tif</FILE3>
<FILE4>\00000000\309.tif</FILE4>
<FILE5>\00000000\310.tif</FILE5>
<FILE6>\00000000\311.tif</FILE6>
<FILE7>\00000000\312.tif</FILE7>
<FILE8>\00000000\313.tif</FILE8>
<FILE9>\00000000\314.tif</FILE9>
</OBJECT>
</DOCUMENT>
<DOCUMENT DOCID="15">
<DOCINDEXFIELD>
<NAME>CASE NUMBER</NAME>
<VALUE>9254</VALUE>
</DOCINDEXFIELD>
<DOCINDEXFIELD>
<NAME>SURNAME</NAME>
<VALUE>MO</VALUE>
</DOCINDEXFIELD>
<DUPEID>0</DUPEID>
<OBJECT>
<OBJTYPE>0</OBJTYPE>
<PAGES>5</PAGES>
<FILE1>\00000000\474.tif</FILE1>
<FILE2>\00000000\475.tif</FILE2>
<FILE3>\00000000\476.tif</FILE3>
<FILE4>\00000000\477.tif</FILE4>
<FILE5>\00000000\478.tif</FILE5>
</OBJECT>
</DOCUMENT>
<DOCUMENT DOCID="16">
<DOCINDEXFIELD>
<NAME>CASE NUMBER</NAME>
<VALUE>9253</VALUE>
</DOCINDEXFIELD>
<DOCINDEXFIELD>
<NAME>SURNAME</NAME>
<VALUE>IN</VALUE>
</DOCINDEXFIELD>
<DUPEID>0</DUPEID>
<OBJECT>
<OBJTYPE>0</OBJTYPE>
<PAGES>22</PAGES>
<FILE1>\00000000\479.tif</FILE1>
<FILE2>\00000000\480.tif</FILE2>
<FILE3>\00000000\481.tif</FILE3>
<FILE4>\00000000\482.tif</FILE4>
<FILE5>\00000000\483.tif</FILE5>
<FILE6>\00000000\484.tif</FILE6>
<FILE7>\00000000\485.tif</FILE7>
<FILE8>\00000000\486.tif</FILE8>
<FILE9>\00000000\487.tif</FILE9>
<FILE10>\00000000\488.tif</FILE10>
<FILE11>\00000000\489.tif</FILE11>
<FILE12>\00000000\490.tif</FILE12>
<FILE13>\00000000\491.tif</FILE13>
<FILE14>\00000000\492.tif</FILE14>
<FILE15>\00000000\493.tif</FILE15>
<FILE16>\00000000\494.tif</FILE16>
<FILE17>\00000000\495.tif</FILE17>
<FILE18>\00000000\496.tif</FILE18>
<FILE19>\00000000\497.tif</FILE19>
<FILE20>\00000000\498.tif</FILE20>
<FILE21>\00000000\499.tif</FILE21>
<FILE22>\00000000\500.tif</FILE22>
</OBJECT>
</DOCUMENT>
<DOCUMENT DOCID="17">
<DOCINDEXFIELD>
<NAME>CASE NUMBER</NAME>
<VALUE>0831</VALUE>
</DOCINDEXFIELD>
<DOCINDEXFIELD>
<NAME>SURNAME</NAME>
<VALUE></VALUE>
</DOCINDEXFIELD>
<DUPEID>0</DUPEID>
<OBJECT>
<OBJTYPE>0</OBJTYPE>
<PAGES>83</PAGES>
<FILE1>\00000000\953.tif</FILE1>
<FILE2>\00000000\954.tif</FILE2>
<FILE3>\00000000\955.tif</FILE3>
<FILE4>\00000000\956.tif</FILE4>
<FILE5>\00000000\957.tif</FILE5>
<FILE6>\00000000\958.tif</FILE6>
<FILE7>\00000000\959.tif</FILE7>
<FILE8>\00000000\960.tif</FILE8>
<FILE9>\00000000\961.tif</FILE9>
<FILE10>\00000000\962.tif</FILE10>
<FILE11>\00000000\963.tif</FILE11>
<FILE12>\00000000\964.tif</FILE12>
<FILE13>\00000000\965.tif</FILE13>
<FILE14>\00000000\966.tif</FILE14>
<FILE15>\00000000\967.tif</FILE15>
<FILE16>\00000000\968.tif</FILE16>
<FILE17>\00000000\969.tif</FILE17>
<FILE18>\00000000\970.tif</FILE18>
<FILE19>\00000000\971.tif</FILE19>
<FILE20>\00000000\972.tif</FILE20>
<FILE21>\00000000\973.tif</FILE21>
<FILE22>\00000000\974.tif</FILE22>
<FILE23>\00000000\975.tif</FILE23>
<FILE24>\00000000\976.tif</FILE24>
<FILE25>\00000000\977.tif</FILE25>
<FILE26>\00000000\978.tif</FILE26>
<FILE27>\00000000\979.tif</FILE27>
<FILE28>\00000000\980.tif</FILE28>
<FILE29>\00000000\981.tif</FILE29>
<FILE30>\00000000\982.tif</FILE30>
<FILE31>\00000000\983.tif</FILE31>
<FILE32>\00000000\984.tif</FILE32>
<FILE33>\00000000\985.tif</FILE33>
<FILE34>\00000000\986.tif</FILE34>
<FILE35>\00000000\987.tif</FILE35>
<FILE36>\00000000\988.tif</FILE36>
<FILE37>\00000000\989.tif</FILE37>
<FILE38>\00000000\990.tif</FILE38>
<FILE39>\00000000\991.tif</FILE39>
<FILE40>\00000000\992.tif</FILE40>
<FILE41>\00000000\993.tif</FILE41>
<FILE42>\00000000\994.tif</FILE42>
<FILE43>\00000000\995.tif</FILE43>
<FILE44>\00000000\996.tif</FILE44>
<FILE45>\00000000\997.tif</FILE45>
<FILE46>\00000000\998.tif</FILE46>
<FILE47>\00000000\999.tif</FILE47>
<FILE48>\00001000\1000.tif</FILE48>
<FILE49>\00001000\1001.tif</FILE49>
<FILE50>\00001000\1002.tif</FILE50>
<FILE51>\00001000\1003.tif</FILE51>
<FILE52>\00001000\1004.tif</FILE52>
<FILE53>\00001000\1005.tif</FILE53>
<FILE54>\00001000\1006.tif</FILE54>
<FILE55>\00001000\1007.tif</FILE55>
<FILE56>\00001000\1008.tif</FILE56>
<FILE57>\00001000\1009.tif</FILE57>
<FILE58>\00001000\1010.tif</FILE58>
<FILE59>\00001000\1011.tif</FILE59>
<FILE60>\00001000\1012.tif</FILE60>
<FILE61>\00001000\1013.tif</FILE61>
<FILE62>\00001000\1014.tif</FILE62>
<FILE63>\00001000\1015.tif</FILE63>
<FILE64>\00001000\1016.tif</FILE64>
<FILE65>\00001000\1017.tif</FILE65>
<FILE66>\00001000\1018.tif</FILE66>
<FILE67>\00001000\1019.tif</FILE67>
<FILE68>\00001000\1020.tif</FILE68>
<FILE69>\00001000\1021.tif</FILE69>
<FILE70>\00001000\1022.tif</FILE70>
<FILE71>\00001000\1023.tif</FILE71>
<FILE72>\00001000\1024.tif</FILE72>
<FILE73>\00001000\1025.tif</FILE73>
<FILE74>\00001000\1026.tif</FILE74>
<FILE75>\00001000\1027.tif</FILE75>
<FILE76>\00001000\1028.tif</FILE76>
<FILE77>\00001000\1029.tif</FILE77>
<FILE78>\00001000\1030.tif</FILE78>
<FILE79>\00001000\1031.tif</FILE79>
<FILE80>\00001000\1032.tif</FILE80>
<FILE81>\00001000\1033.tif</FILE81>
<FILE82>\00001000\1034.tif</FILE82>
<FILE83>\00001000\1035.tif</FILE83>
</OBJECT>
</DOCUMENT>
</DOCUMENTS>
</PROJECT>
</PFDM_DATAGRP>
&#13;
这是我的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" exclude-result-prefixes="msxsl"
>
<xsl:template match="/">
<xsl:text> </xsl:text>
<xsl:for-each select ="PFDM_DATAGRP/PROJECT/DOCUMENTS/DOCUMENT">
<xsl:text>"</xsl:text>
<xsl:value-of select="DOCINDEXFIELD[1]/VALUE"/>
<xsl:text>"</xsl:text>
<xsl:value-of select ="','"/>
<xsl:text>"</xsl:text>
<xsl:value-of select="DOCINDEXFIELD[2]/VALUE"/>
<xsl:text>"</xsl:text>
<xsl:value-of select ="','"/>
</xsl:for-each>
<xsl:for-each select ="PFDM_DATAGRP/PROJECT/DOCUMENTS/DOCUMENT/OBJECT">
<xsl:text>"</xsl:text>
<xsl:value-of select ="."/>
<xsl:text>"</xsl:text>
<xsl:if test ="position() != last()">
<xsl:value-of select ="','"/>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
&#13;
很抱歉这个烂摊子但是我不得不停下来寻求帮助然后让它变得更糟。 感谢您阅读本文
答案 0 :(得分:0)
这样的事情对你有用吗?
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:for-each select="PFDM_DATAGRP/PROJECT/DOCUMENTS/DOCUMENT">
<xsl:variable name="case-number" select="DOCINDEXFIELD[NAME='CASE NUMBER']/VALUE" />
<xsl:variable name="surname" select="DOCINDEXFIELD[NAME='SURNAME']/VALUE" />
<xsl:for-each select="OBJECT/*[starts-with(name(), 'FILE')]">
<xsl:text>"</xsl:text>
<xsl:value-of select ="$case-number"/>
<xsl:text>","</xsl:text>
<xsl:value-of select ="$surname"/>
<xsl:text>","</xsl:text>
<xsl:value-of select ="."/>
<xsl:text>"</xsl:text>
<xsl:if test ="position() != last()">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:if test ="position() != last()">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
答案 1 :(得分:0)
我对这些要求并不完全确定,但似乎问题是你没有在正确的元素上循环(每行必须反映一个文件,不是吗?)以下怎么样?
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="PFDM_DATAGRP/PROJECT/DOCUMENTS/DOCUMENT/OBJECT/*[starts-with(local-name(.), 'FILE')]">
<xsl:text>"</xsl:text>
<xsl:value-of select="../../DOCINDEXFIELD[1]/NAME"/>
<xsl:text>","</xsl:text>
<xsl:value-of select="../../DOCINDEXFIELD[2]/NAME"/>
<xsl:text>","</xsl:text>
<xsl:value-of select="."/>
<xsl:text>" </xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
答案 2 :(得分:0)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="PFDM_DATAGRP/PROJECT/DOCUMENTS/DOCUMENT/OBJECT/*[starts-with(local-name(.), 'FILE')]">
<xsl:text>"</xsl:text>
<xsl:value-of select="../../DOCINDEXFIELD[1]/VALUE"/>
<xsl:text>","</xsl:text>
<xsl:value-of select="../../DOCINDEXFIELD[2]/VALUE"/>
<xsl:text>","</xsl:text>
<xsl:value-of select="."/>
<xsl:text>" </xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
&#13;