Connecting Tech Pros Worldwide Forums | Help | Site Map

XML schema transformation with XSLT

Newbie
 
Join Date: Nov 2008
Posts: 9
#1: Mar 3 '09
hi all,
I need to transform an xml file into a different format (Dublin Core schema) using xslt, file contains different records each record needs to transformed based on a unique ID (in this case its element <guid>) that represents the record. Input file is:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <ListRecords>
  3. <record>
  4. <header>
  5. <identifier>Project_DEM_100</identifier>
  6. <datestamp>2000-02-14T09:23:25Z</datestamp>
  7. </header>
  8. <metadata>
  9. <group xsi:noNamespaceSchemaLocation="http://url.for.schema/schema.xsd">
  10. <title>USER.765</title>
  11. <feed>
  12. <title>My feed</title>
  13. <url>no.url.available</url>
  14. <item>
  15. <!-- Here guid is the unique id for each of the records and also for transformation into another xml format -->
  16. <guid>oai:triple-l:2c7ba037-52a6-4323-97dd-b6ea1cdbfd18:340</guid>
  17. <events>
  18. <event>
  19. <dateTime>2000-03-26T13:27:49.00</dateTime>
  20. <action>
  21. <actionType>doSomeAtcion</actionType>
  22. <relatedData>
  23. <metadata>
  24. <lom xsi:schemaLocation="http://ltsc.ieee.org/xsd/LOM">
  25. <general >
  26. <identifier>
  27. <entry>340</entry>
  28. </identifier>
  29. <identifier>
  30. <identifier>
  31. <catalog>oai</catalog>
  32. <entry>oai:triple-l:2c7ba037-52a6-4323-97dd-b6ea1cdbfd18:340</entry>
  33. </identifier
  34. <title>
  35. <langstring>
  36. <value>Graduation mw. S. de Caralt</value>
  37. <language>en</language>
  38. </langstring>
  39. </title>
  40. <catalogentry>
  41. <catalog>nl.wur.wurtv</catalog>
  42. <entry>
  43. <langstring>
  44. <value>340</value>
  45. <language>x-none</language>
  46. </langstring>
  47. </entry>
  48. </catalogentry>
  49. <grouplanguage>en</grouplanguage>
  50. <description>
  51. <langstring>
  52. <value>Sponge Culture: Learning from Biology and Ecology</value>
  53. <language>en</language>
  54. </langstring>
  55. </description>
  56. </general>
  57. <metametadata >
  58. <identifier>
  59. <entry>340</entry>
  60. </identifier>
  61. <identifier>
  62. <catalog>oai</catalog>
  63. <entry>oai:triple-l:2c7ba037-52a6-4323-97dd-b6ea1cdbfd18:340</entry>
  64. </identifier>
  65. <contribute>
  66. <date>
  67. <dateTime>2001-12-01T00:00:00.00Z</dateTime>
  68. </date>
  69. </contribute>
  70. <contribute>
  71. <role>
  72. <source>PROJECT1.0</source>
  73. <value>provider</value>
  74. </role>
  75. <entity>
  76. BEGIN:VCARD User VERSION:3.0 END:VCARD
  77. </entity>
  78. <date>
  79. <dateTime>2001-10-10T15:56:17.58Z</dateTime>
  80. </date>
  81. </contribute>
  82. <metadatascheme>LORENET</metadatascheme>
  83. </metametadata>
  84. </lom>
  85. </metadata>
  86. </relatedData>
  87. </action>
  88. </event>
  89. </events>
  90. </item>
  91. </feed>
  92. </group>
  93. </metadata>
  94. </record>
  95. <record>
  96. <!-- similar other records that are distnguished with unique id's (guid element) -->
  97. </record>
  98. </ListRecords>
The oupt file should be:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <ListRecords>
  3. <record>
  4. <dc:header>Project_DEM_100</dc:header>
  5. <dc:date>2000-02-14T09:23:25Z</dc:date>
  6. <metadata>
  7. <group xsi:noNamespaceSchemaLocation="http://url.for.schema/schema.xsd">
  8. <dc:title>USER.765</dc:title>
  9. <dc:feedData>
  10. <dc:title>My feed</dc:title>
  11. <dc:url>no.url.available</dc:url>
  12. <dc:item>
  13. <!-- Here identifier is the unique id for each of the records and guid element is changed into identifier element -->
  14. <dc:identifier>oai:triple-l:2c7ba037-52a6-4323-97dd-b6ea1cdbfd18:340</dc:identifier>
  15. <dc:events>
  16. <dc:event>
  17. <dc:dateTime>2000-03-26T13:27:49.00</dc:dateTime>
  18. <dc:userAction>
  19. <dc:actionType>doSomeAtcion</dc:actionType>
  20. <dc:relatedData>
  21. <metadata>
  22. <lom xsi:schemaLocation="http://ltsc.ieee.org/xsd/LOM">
  23. <general >
  24. <dc:identifier>340</dc:identifier>
  25. <identifier>
  26. <dc:identifier>oa1,oai:triple-l:2c7ba037-52a6-4323-97dd-b6ea1cdbfd18:340</identifier
  27. <dc:title>Graduation mw. S. de Caralt</dc:title>
  28. <dc:catalogentry>
  29. <dc:catalog>nl.wur.wurtv</dc:catalog>
  30. <dc:language>x-none</dc:language>
  31. </dc:catalogentry>
  32. <dc:language>en</dc:language>
  33. <dc:description>Sponge Culture: Learning from Biology and Ecology</dc:description>
  34. </general>
  35. <metametadata >
  36. <dc:identifier>340</identifier>
  37. <dc:identifier>oai, oai:triple-l:2c7ba037-52a6-4323-97dd-b6ea1cdbfd18:340</dc:identifier>
  38. <dc:contribute>
  39. <dc:date>2001-10-10T15:56:17.58Z</dc:date>
  40. </dc:contribute>
  41. <dc:contribute>
  42. <dc:role>PROJECT1.0,provide</dc:role>
  43. <entity>
  44. BEGIN:VCARD User VERSION:3.0 END:VCARD
  45. </entity>
  46. <dc:date>2001-10-10T15:56:17.58Z</dc:date>
  47. </dc:contribute>
  48. <dc:metadatascheme>LORENET</dc:metadatascheme>
  49. </metametadata>
  50. </lom>
  51. </metadata>
  52. </dc:relatedData>
  53. </dc:userAction>
  54. </dc:event>
  55. </dc:events>
  56. </dc:item>
  57. </dc:feedData>
  58. </group>
  59. </metadata>
  60. </record>
  61. <record>
  62. <!-- similar other records that are distnguished with unique id's (guid element) and trasnformed into above format -->
  63. </record>
  64. </ListRecords>
I don't know anything about xslt so need help about how this tranformation can be done..
Thnx. & regards..

Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,664
#2: Mar 3 '09

re: XML schema transformation with XSLT


I think the best for you is to start with a tutorial (XSLT @ w3schools) to get used to the language.

if you run into problem, just ask us.

regards
Reply