XSL elements from attributes

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

Join Date: Mar 2009
Posts: 1
Reputation: RobertGaut is an unknown quantity at this point 
Solved Threads: 0
RobertGaut RobertGaut is offline Offline
Newbie Poster

XSL elements from attributes

 
0
  #1
Mar 18th, 2009
Given the following XML:

<FlowDocument>
     <Run FontStyle="Italic" FontWeight="Bold">test</Run>
</FlowDocument>

How could I get this result?:

<body>
     <em><strong>test</strong></em>
</body>

Thanks in advance!
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 831
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 136
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Practically a Posting Shark

Re: XSL elements from attributes

 
0
  #2
Mar 19th, 2009
XML, XSLT and XPATH Syntax (Toggle Plain Text)
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <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">
  3. <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
  4.  
  5. <xsl:template match="FlowControl">
  6. <body>
  7. <xsl:apply-templates select="Run" />
  8. </body>
  9. </xsl:template>
  10.  
  11. <xsl:template match="Run">
  12. <xsl:if test="@FontStyle = 'Italic'">
  13. <xsl:text disable-output-escaping="yes">&lt;em&gt;</xsl:text>
  14. </xsl:if>
  15. <xsl:if test="@FontWeight = 'Bold'">
  16. <xsl:text disable-output-escaping="yes">&lt;strong&gt;</xsl:text>
  17. </xsl:if>
  18. <xsl:value-of select="."/>
  19. <xsl:if test="@FontWeight = 'Bold'">
  20. <xsl:text disable-output-escaping="yes">&lt;/strong&gt;</xsl:text>
  21. </xsl:if>
  22. <xsl:if test="@FontStyle = 'Italic'">
  23. <xsl:text disable-output-escaping="yes">&lt;/em&gt;</xsl:text>
  24. </xsl:if>
  25. </xsl:template>
  26. </xsl:stylesheet>
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 95
Reputation: fpmurphy is an unknown quantity at this point 
Solved Threads: 5
fpmurphy fpmurphy is offline Offline
Junior Poster in Training

Re: XSL elements from attributes

 
1
  #3
Mar 20th, 2009
Typo
XML, XSLT and XPATH Syntax (Toggle Plain Text)
  1.  
  2. <xsl:template match="FlowControl">
should be
XML, XSLT and XPATH Syntax (Toggle Plain Text)
  1. <xsl:template math="FlowDocument">
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
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