944,202 Members | Top Members by Rank

Ad:
Nov 1st, 2009
0

Convert XML file to another XML file using XSLT

Expand Post »
I need to convert the following XML file
xml Syntax (Toggle Plain Text)
  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; Nov 5th, 2009 at 4:03 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sushil.sharma75 is offline Offline
2 posts
since Nov 2009
Nov 4th, 2009
0

Convert XML using XSLT

I need to convert the following XML
xml Syntax (Toggle Plain Text)
  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; Nov 5th, 2009 at 4:03 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sushil.sharma75 is offline Offline
2 posts
since Nov 2009
Nov 5th, 2009
0
Re: Convert XML file to another XML file using XSLT
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?
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in XML, XSLT and XPATH Forum Timeline: Nesting of xsl:key() within xsl:key() & combining results of xsl:key()
Next Thread in XML, XSLT and XPATH Forum Timeline: XPath Expression to calculate total amount for order details





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC