Convert XML file to another XML file using XSLT

Please support our XML, XSLT and XPATH advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2009
Posts: 2
Reputation: sushil.sharma75 is an unknown quantity at this point 
Solved Threads: 0
sushil.sharma75 sushil.sharma75 is offline Offline
Newbie Poster

Convert XML file to another XML file using XSLT

 
0
  #1
26 Days Ago
I need to convert the following XML file
  1. <Para>
  2. <PgfTag value="Body" type="str"/>
  3. <Pgf>
  4. <PgfFont>
  5. <FFamily value="Times New Roman" type="str"/>
  6. <FWeight value="Regular" type="str"/>
  7. </PgfFont>
  8. </Pgf>
  9. <ParaLine>
  10. <String>Underlined charcter</String>
  11. </ParaLine>
  12. </Para>
  13. <Para>
  14. <PgfTag value="Body" type="str"/>
  15. <Pgf>
  16. <PgfFont>
  17. <FFamily value="Times New Roman" type="str"/>
  18. <FWeight value="Regular" type="str"/>
  19. <FAngle value="Italic" type="str"/>
  20. </PgfFont>
  21. </Pgf>
  22. <ParaLine>
  23. <String>Italic charcter</String>
  24. </ParaLine>
  25. </Para>

to

XML, XSLT and XPATH Syntax (Toggle Plain Text)
  1. <styles>
  2. <style family="paragraph" name="P1">
  3. <paragraph-properties line-height-at-least="0.1945in" text- autospace="none" />
  4. <text-properties text-underline-style="solid" text-underline-width="auto"/>
  5. </style>
  6. <style family="paragraph" name="P2">
  7. <paragraph-properties line-height-at-least="0.1945in" text-autospace="none">
  8. </paragraph-properties>
  9. <text-properties font-style="italic">
  10. </text-properties>
  11. </style>
  12. </styles>
  13. <body>
  14. <texts>
  15. <text style-name="P1">
  16. Underlined charcter
  17. </text>
  18. <text style-name="P2">
  19. Italic charcter
  20. </text>
  21. </texts>
  22. </body>

I am able to get the styles tags but how Can I get the Texts tags with style-names as P1 and P2

Thank you in advance
Last edited by peter_budo; 23 Days Ago at 4:03 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 2
Reputation: sushil.sharma75 is an unknown quantity at this point 
Solved Threads: 0
sushil.sharma75 sushil.sharma75 is offline Offline
Newbie Poster

Convert XML using XSLT

 
0
  #2
23 Days Ago
I need to convert the following XML
  1. <Para>
  2. <Unique value="998197" type="enum" />
  3. <PgfTag value="Body" type="str" />
  4. <Pgf>
  5. <PgfFont>
  6. <FFamily value="Times New Roman" type="str" />
  7. </PgfFont>
  8. </Pgf>
  9. <ParaLine>
  10. <TextRectID value="19" type="enum" />
  11. <String>Sushil Font Time Roman </String>
  12. <Font>
  13. <FFamily value="Garamond" type="str" />
  14. </Font>
  15. <String>Sharma Font Garamond</String>
  16. </ParaLine>
  17. </Para>

to XML

XML, XSLT and XPATH Syntax (Toggle Plain Text)
  1. <automatic-styles>
  2. <style name="P1" family="paragraph">
  3. <text-properties font-style="Regular" font-size="10.0" font-name="Times New Roman" />
  4. </style>
  5. <style name="T1" family="text">
  6. <text-properties font-name="Garamond" />
  7. </style>
  8. </automatic-styles>
  9.  
  10.  
  11. <texts>
  12. <text style-name="P1">
  13. Sushil Font Time Roman
  14. <span style-name="T1">
  15. Sharma Font Garamond
  16. </span>
  17. </text>
  18. </texts>

There can be multiple Para in the input XML. so there will be multiple style as P1 , P2, P3 , T1, T2 etc

Thank you for your reply
Last edited by peter_budo; 23 Days Ago at 4:03 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,612
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 463
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven
 
0
  #3
23 Days Ago
sushil.sharma75,

XSLT is a language for converting XML documents into other documents. Because XSLT is itself an XML vocabulary, it is possible to generate XSLT stylesheets as the output of a transformation, but it's unusual and not for beginners. What do you actually want to achieve?
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Reply

Message:



Other Threads in the XML, XSLT and XPATH Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC