Removing Span Tag ? [modified]
-
Hi, I am displaying some information using XSLT. But in the output span tags are displayed, whereas it should be removed automatically. 1span class="b1"2 heart attack 1/span2 - Contact us where, 1 = < 2 = > Above output is absoultely correct but the only problem is span tags. Is there any way i can remove this span tags from the output using xslt or if there is any other way out ? Thanks Andy
modified on Monday, January 12, 2009 11:41 AM
-
Hi, I am displaying some information using XSLT. But in the output span tags are displayed, whereas it should be removed automatically. 1span class="b1"2 heart attack 1/span2 - Contact us where, 1 = < 2 = > Above output is absoultely correct but the only problem is span tags. Is there any way i can remove this span tags from the output using xslt or if there is any other way out ? Thanks Andy
modified on Monday, January 12, 2009 11:41 AM
If it is actually reading ... heart attack /span> - Contact Us It seems there is an excess of >'s there. ------------------------------------ "The greatest tragedy in mankind's entire history may be the hijacking of morality by religion" Arthur C Clarke
-
If it is actually reading ... heart attack /span> - Contact Us It seems there is an excess of >'s there. ------------------------------------ "The greatest tragedy in mankind's entire history may be the hijacking of morality by religion" Arthur C Clarke
Check now... It is something i am unable to control really. we have our own search engine powered by vivisimo. I am trying to customize the search output by XSLT. The below statment is used to extract the title of the search result. 1xsl:value-of select="content[@name='title']" /2 So when title is extracted span tags are also displayed like i said in my last post. Any way to sort this out ?? Thannks
modified on Monday, January 12, 2009 11:41 AM
-
Check now... It is something i am unable to control really. we have our own search engine powered by vivisimo. I am trying to customize the search output by XSLT. The below statment is used to extract the title of the search result. 1xsl:value-of select="content[@name='title']" /2 So when title is extracted span tags are also displayed like i said in my last post. Any way to sort this out ?? Thannks
modified on Monday, January 12, 2009 11:41 AM
Not easily. If it is just for on screen reference, you could convert it to text and subtract the tags and then re assign the variable the new value.
------------------------------------ "The greatest tragedy in mankind's entire history may be the hijacking of morality by religion" Arthur C Clarke
-
Not easily. If it is just for on screen reference, you could convert it to text and subtract the tags and then re assign the variable the new value.
------------------------------------ "The greatest tragedy in mankind's entire history may be the hijacking of morality by religion" Arthur C Clarke
-
Check now... It is something i am unable to control really. we have our own search engine powered by vivisimo. I am trying to customize the search output by XSLT. The below statment is used to extract the title of the search result. 1xsl:value-of select="content[@name='title']" /2 So when title is extracted span tags are also displayed like i said in my last post. Any way to sort this out ?? Thannks
modified on Monday, January 12, 2009 11:41 AM
I am not really sure what you are try to do. However, I believe you want to parse mixed text and element nodes. I was able to do what you desired with the following short examples: [XML input]
<?xml version="1.0" encoding="utf-8"?>
<contents>
<content name="title">
<span class="b1">Heart Attack</span> - Contact us
</content>
</contents>[XSLT]
<?xml version="1.0" encoding="utf-8"?>
<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"<xsl:output method="xml" indent="yes"/>
<xsl:template match="/contents">
<results>
<xsl:apply-templates select="content[@name='title']"/>
</results>
</xsl:template><xsl:template match="content">
<result>
<xsl:value-of select="."/>
</result>
</xsl:template>
</xsl:stylesheet>[XML output]
<?xml version="1.0" encoding="utf-8"?>
<results>
<result>
Heart Attack - Contact us
</result>
</results>"We make a living by what we get, we make a life by what we give." --Winston Churchill
-
I am not really sure what you are try to do. However, I believe you want to parse mixed text and element nodes. I was able to do what you desired with the following short examples: [XML input]
<?xml version="1.0" encoding="utf-8"?>
<contents>
<content name="title">
<span class="b1">Heart Attack</span> - Contact us
</content>
</contents>[XSLT]
<?xml version="1.0" encoding="utf-8"?>
<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"<xsl:output method="xml" indent="yes"/>
<xsl:template match="/contents">
<results>
<xsl:apply-templates select="content[@name='title']"/>
</results>
</xsl:template><xsl:template match="content">
<result>
<xsl:value-of select="."/>
</result>
</xsl:template>
</xsl:stylesheet>[XML output]
<?xml version="1.0" encoding="utf-8"?>
<results>
<result>
Heart Attack - Contact us
</result>
</results>"We make a living by what we get, we make a life by what we give." --Winston Churchill
-
What software or API are you using? Could you provide a snippet of your code and data?
"We make a living by what we get, we make a life by what we give." --Winston Churchill
-
What software or API are you using? Could you provide a snippet of your code and data?
"We make a living by what we get, we make a life by what we give." --Winston Churchill
Well basically its a search engine powered by vivisimo. i am using vivisimo admin tool to boost certail result. For instance:-
<xsl:template match="/">
<scope>
<xsl:copy-of select="/scope/attribute" />
<boost name="df" />
<xsl:apply-templates />
</scope>
</xsl:template>
<xsl:template match="document">
<document url="{@url}">
<xsl:if test="viv:test(content[@name='snippet'], 'heart', 'case-insensitive-regex')">
<xsl:attribute name="boost-name">df</xsl:attribute>
<xsl:attribute name="boost-display">boost-and-list</xsl:attribute>
</xsl:if>
<xsl:copy-of select="@*" />
<xsl:copy-of select="* | text() | comment()" />
</document>
</xsl:template>The above code boost the result with heart word in snippet after any search made.
<xsl:output omit-xml-declaration="yes" />
<xsl:template match="boost" mode="list-boost-custom">
<fieldset style="border: 2px solid orange">
<legend style="font-size: 120%; color: #555">Good Choices:</legend>
<ul style="list-style-type:none; padding: 0 0.5em">
<xsl:for-each select="document">
<li style="margin: 0.5em 0;">
<span>
<a href="{@url}">
<xsl:value-of select="content[@name='title']" />
</a>
</span>
</li>
</xsl:for-each>
</ul>
</fieldset>
</xsl:template>The above code provide a column for a good choices where the boosted result titles are displayed. Now everything is working fine. I am getting the titles but along with the titles i am also getting span tag as i mentioned before but yeh few of the titles are fine but most of them contain this span tag several times. Any idea about this ?? Also i would like to ask if there is any way i can also include image along with the title, may be below title (if there is image included with the the boosted page) Thanks Andyyy
modified on Tuesday, January 20, 2009 5:12 AM
-
Well basically its a search engine powered by vivisimo. i am using vivisimo admin tool to boost certail result. For instance:-
<xsl:template match="/">
<scope>
<xsl:copy-of select="/scope/attribute" />
<boost name="df" />
<xsl:apply-templates />
</scope>
</xsl:template>
<xsl:template match="document">
<document url="{@url}">
<xsl:if test="viv:test(content[@name='snippet'], 'heart', 'case-insensitive-regex')">
<xsl:attribute name="boost-name">df</xsl:attribute>
<xsl:attribute name="boost-display">boost-and-list</xsl:attribute>
</xsl:if>
<xsl:copy-of select="@*" />
<xsl:copy-of select="* | text() | comment()" />
</document>
</xsl:template>The above code boost the result with heart word in snippet after any search made.
<xsl:output omit-xml-declaration="yes" />
<xsl:template match="boost" mode="list-boost-custom">
<fieldset style="border: 2px solid orange">
<legend style="font-size: 120%; color: #555">Good Choices:</legend>
<ul style="list-style-type:none; padding: 0 0.5em">
<xsl:for-each select="document">
<li style="margin: 0.5em 0;">
<span>
<a href="{@url}">
<xsl:value-of select="content[@name='title']" />
</a>
</span>
</li>
</xsl:for-each>
</ul>
</fieldset>
</xsl:template>The above code provide a column for a good choices where the boosted result titles are displayed. Now everything is working fine. I am getting the titles but along with the titles i am also getting span tag as i mentioned before but yeh few of the titles are fine but most of them contain this span tag several times. Any idea about this ?? Also i would like to ask if there is any way i can also include image along with the title, may be below title (if there is image included with the the boosted page) Thanks Andyyy
modified on Tuesday, January 20, 2009 5:12 AM
I am not at all familiar with Vivismo. However, the first code snippet contains the following:
<xsl:copy-of select="@*" /><xsl:copy-of select="* | text() | comment()" />
This code copies everything. The second code snippet actually has a span tag in the code. Wouldn't that span tag get copied to the output?
<li style="margin: 0.5em 0;"><span><a href="{@url}"><xsl:value-of select="content[@name='title']" /></a></span></li>
"We make a living by what we get, we make a life by what we give." --Winston Churchill
-
I am not at all familiar with Vivismo. However, the first code snippet contains the following:
<xsl:copy-of select="@*" /><xsl:copy-of select="* | text() | comment()" />
This code copies everything. The second code snippet actually has a span tag in the code. Wouldn't that span tag get copied to the output?
<li style="margin: 0.5em 0;"><span><a href="{@url}"><xsl:value-of select="content[@name='title']" /></a></span></li>
"We make a living by what we get, we make a life by what we give." --Winston Churchill
You don't have to know the vivisimo for this i reckon. If i remove the first line of code. I don't get any web page detail like title, snippet etc but i do get only the link (For instance when you search in google, imagine if it gives you result without any title or any discription below that but just a NO Title option to click and get to that page) And i have already tried removing span tag from the second line of code but it doesn't make any difference really. I think the main problem is with the display code. If you come up with your own code which can do similar stuff but without span tag then it would be great. Here is one link which do something similar. But i can't figure out how to use it in my code. http://dotnetslackers.com/Community/blogs/kaushalparik/archive/2008/08/30/strip-out-html-tags-to-display-plain-text-in-xslt.aspx[^]
-
You don't have to know the vivisimo for this i reckon. If i remove the first line of code. I don't get any web page detail like title, snippet etc but i do get only the link (For instance when you search in google, imagine if it gives you result without any title or any discription below that but just a NO Title option to click and get to that page) And i have already tried removing span tag from the second line of code but it doesn't make any difference really. I think the main problem is with the display code. If you come up with your own code which can do similar stuff but without span tag then it would be great. Here is one link which do something similar. But i can't figure out how to use it in my code. http://dotnetslackers.com/Community/blogs/kaushalparik/archive/2008/08/30/strip-out-html-tags-to-display-plain-text-in-xslt.aspx[^]
When I come home from work, I will take a look at this.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
-
When I come home from work, I will take a look at this.
"We make a living by what we get, we make a life by what we give." --Winston Churchill