rvdokkum Posted June 2, 2011 Share Posted June 2, 2011 when using <xsl:value-of select="audio-caption"/>how do i get the text without the <p> </p>adding /p did not work : <xsl:value-of select="audio-caption/p"/>example of similar full xml file : http://staff.tumblr.com/api/readpart of my xml: <?xml version="1.0" encoding="UTF-8"?>......<post><audio-caption><p>Test audio post of a ringtone.</p></audio-caption> part of my xsl: <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"> <h2>Blog</h2> <table> <xsl:for-each select="tumblr/posts/post"> <tr> <td> <xsl:choose> <xsl:when test="@type='audio'"> <xsl:element name="a"><xsl:attribute name="href"><xsl:value-of select="@url"/> </xsl:attribute> <xsl:value-of select="audio-caption"/> </xsl:element> Link to comment Share on other sites More sharing options...
Martin Honnen Posted June 2, 2011 Share Posted June 2, 2011 Frankly xsl: value-of should never give you markup, unless it is contained in the node in escaped form (e.g. <audio-caption><![CDATA[<p>Test audio post of a ringtone.</p>]]></audio-caption> ).So I am currently not sure which problem you face, unless the input is different from what you posted. Please clarify. You might also want to mention which XSLT version (1.0 or 2.0) you use, that helps anyone trying to answer your posts to show you the right approach. Link to comment Share on other sites More sharing options...
rvdokkum Posted June 2, 2011 Author Share Posted June 2, 2011 Frankly xsl: value-of should never give you markup, unless it is contained in the node in escaped form (e.g.<audio-caption><![CDATA[<p>Test audio post of a ringtone.</p>]]></audio-caption> ).So I am currently not sure which problem you face, unless the input is different from what you posted. Please clarify. You might also want to mention which XSLT version (1.0 or 2.0) you use, that helps anyone trying to answer your posts to show you the right approach. thanks for the info.i added the required info to original post.there is nothing that can be done about the xml data. thats how tumblr generates it. Link to comment Share on other sites More sharing options...
rvdokkum Posted June 2, 2011 Author Share Posted June 2, 2011 thanks for the info.i added the required info to original post.there is nothing that can be done about the xml data. thats how tumblr generates it.if i change the versions of xml and xsl to 2.0 then i can use the replace function to delete the <p> an </p>fn:replace(string,pattern,replace) - http://www.w3schools.com/Xpath/xpath_functions.aspwill the latest browsers on mac and windows support xml xsl v2? Link to comment Share on other sites More sharing options...
rvdokkum Posted June 2, 2011 Author Share Posted June 2, 2011 if i change the versions of xml and xsl to 2.0 then i can use the replace function to delete the <p> an </p>fn:replace(string,pattern,replace) - http://www.w3schools.com/Xpath/xpath_functions.aspwill the latest browsers on mac and windows support xml xsl v2?how do i use the replace function to delete <p> and </p> at the end of the variable $long_audio_caption?part of my xsl code:<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"> <h2>Blog</h2> <table> <xsl:for-each select="tumblr/posts/post"> <tr> <td> <xsl:choose> <xsl:when test="@type='audio'"> <xsl:text>audio node</xsl:text> <xsl:variable name="long_audio_caption"> <xsl:value-of select="audio-caption"/> </xsl:variable> <xsl:copy-of select="$long_audio_caption" /> for now i use this workaround : http://geekswithblogs.net/Erik/archive/200.../01/120915.aspx Link to comment Share on other sites More sharing options...
Martin Honnen Posted June 3, 2011 Share Posted June 3, 2011 So your elements do not contain "p" elements but rather text nodes with escaped HTML markup. In that case if you don't want to output the escaped markup you have to remove it with text processing, in XSLT 1.0 you indeed need to use named templates, with XSLT 2.0 you can use replace. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.