Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Removing Span Tag ? [modified]

Removing Span Tag ? [modified]

Scheduled Pinned Locked Moved XML / XSL
xmlhelpquestion
13 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AndyInUK
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • A AndyInUK

      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

      D Offline
      D Offline
      Dalek Dave
      wrote on last edited by
      #2

      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

      A 1 Reply Last reply
      0
      • D Dalek Dave

        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

        A Offline
        A Offline
        AndyInUK
        wrote on last edited by
        #3

        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

        D G 2 Replies Last reply
        0
        • A AndyInUK

          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

          D Offline
          D Offline
          Dalek Dave
          wrote on last edited by
          #4

          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

          A 1 Reply Last reply
          0
          • D Dalek Dave

            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

            A Offline
            A Offline
            AndyInUK
            wrote on last edited by
            #5

            can you show that please to get a better idea..

            1 Reply Last reply
            0
            • A AndyInUK

              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

              G Offline
              G Offline
              George L Jackson
              wrote on last edited by
              #6

              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

              A 1 Reply Last reply
              0
              • G George L Jackson

                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

                A Offline
                A Offline
                AndyInUK
                wrote on last edited by
                #7

                Thanks but it is still not removing span tags.

                G 1 Reply Last reply
                0
                • A AndyInUK

                  Thanks but it is still not removing span tags.

                  G Offline
                  G Offline
                  George L Jackson
                  wrote on last edited by
                  #8

                  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

                  A 1 Reply Last reply
                  0
                  • G George L Jackson

                    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

                    A Offline
                    A Offline
                    AndyInUK
                    wrote on last edited by
                    #9

                    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

                    G 1 Reply Last reply
                    0
                    • A AndyInUK

                      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

                      G Offline
                      G Offline
                      George L Jackson
                      wrote on last edited by
                      #10

                      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

                      A 1 Reply Last reply
                      0
                      • G George L Jackson

                        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

                        A Offline
                        A Offline
                        AndyInUK
                        wrote on last edited by
                        #11

                        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[^]

                        G 1 Reply Last reply
                        0
                        • A AndyInUK

                          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[^]

                          G Offline
                          G Offline
                          George L Jackson
                          wrote on last edited by
                          #12

                          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

                          A 1 Reply Last reply
                          0
                          • G George L Jackson

                            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

                            A Offline
                            A Offline
                            AndyInUK
                            wrote on last edited by
                            #13

                            Hi, Any luck with it so far ? Also i am wondering if there is any way i can extract the image from the html web page and change its dimensions and display it next to the search result. Thanks Andyyy

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups