CSV file from xml using xslt -
i super stuck , know can not sure how ask here goes hope.
end results needed: csv file xml using xslt - each image in file
"case number","surename","\00000000\231.tif"
here have , can see not close. case numbers , sure names , image file numbers cant them separate each image.
my xml file:
<?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>
and here xslt file:
<?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>
sorry mess had stop , ask before make worse. thank reading this
i not entirely sure on requirements, seems problem not loop on correct element (each line must reflect file, not it?) following?
<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>
Comments
Post a Comment