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. Using XSL to filter the data from XML

Using XSL to filter the data from XML

Scheduled Pinned Locked Moved XML / XSL
xmldatabasehelpquestion
4 Posts 2 Posters 14 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hello, I am storing the database data in the XML file. Using the XSL file I want to retrieve the selected data from the XML file. I have tried using , , , but I am not getting the desired results. If I use , the page is not rendered & the drop down control is displayed as a plain text. If I use , the condition is not being tested. Can anypne tell me exactly what could be the problem? Thanks in advance Hitesh

    M 1 Reply Last reply
    0
    • L Lost User

      Hello, I am storing the database data in the XML file. Using the XSL file I want to retrieve the selected data from the XML file. I have tried using , , , but I am not getting the desired results. If I use , the page is not rendered & the drop down control is displayed as a plain text. If I use , the condition is not being tested. Can anypne tell me exactly what could be the problem? Thanks in advance Hitesh

      M Offline
      M Offline
      MS le Roux
      wrote on last edited by
      #2

      It would help a lot if you could provide an example of your XML and what you are trying to retrieve. <tip>Write < when you want to show the < character.</tip> ;)

      L 1 Reply Last reply
      0
      • M MS le Roux

        It would help a lot if you could provide an example of your XML and what you are trying to retrieve. <tip>Write < when you want to show the < character.</tip> ;)

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Hi, Thanks for the reply. Following is the part of the code Credit Card Option1 D2 Credit Card Option1 D2 Credit Card Option1 D2 CardType is the tag in my XML file. Based on the value of CardType selected, I want to display the values from the XML file. Let me know if you can understand this. I wanted to attach my .xsl file but there is no way I can attach the file. Thanks Hitesh

        M 1 Reply Last reply
        0
        • L Lost User

          Hi, Thanks for the reply. Following is the part of the code Credit Card Option1 D2 Credit Card Option1 D2 Credit Card Option1 D2 CardType is the tag in my XML file. Based on the value of CardType selected, I want to display the values from the XML file. Let me know if you can understand this. I wanted to attach my .xsl file but there is no way I can attach the file. Thanks Hitesh

          M Offline
          M Offline
          MS le Roux
          wrote on last edited by
          #4

          I'm guessing your XML looks something like this:

          <cards>
          <card><CardType>1</CardType>
          <data>
          <record>
          <field1>
          <CardLicenceOption>1</CardLicenceOption>
          <CardLicenceOptionDescription>Credit</CardLicenceOptionDescription>
          </field1>
          <field1>
          <CardLicenceOption>2</CardLicenceOption>
          <CardLicenceOptionDescription>Charge</CardLicenceOptionDescription>
          </field1>
          </record>
          </data>
          </card>
          <card><CardType>3</CardType>
          <CardOptionParent1>1</CardOptionParent1>
          <CardOptionDescription>Cash</CardOptionDescription>
          </card>
          </cards>

          It looks like you're using incorrect paths to access your XML elements. The following XSLT should work:

          <xsl:for-each select="//card">
          <tr><td width="50%">Credit Card Option1
          xsl:choose

          <xsl:when test="CardType=3">
          <xsl:element name="select">
          <xsl:attribute name="name">D2</xsl:attribute>
          <xsl:element name="option">
          <xsl:attribute name="value">
          <xsl:value-of select="CardOptionParent1" />
          </xsl:attribute>
          <xsl:value-of select="CardOptionDescription" />
          </xsl:element>
          </xsl:element>
          </xsl:when>

          <xsl:when test="CardType=4">
          <xsl:element name="select">
          <xsl:attribute name="name">D2</xsl:attribute>
          <xsl:element name="option">
          <xsl:attribute name="value">
          <xsl:value-of select="CardOptionParent2" />
          </xsl:attribute>
          <xsl:value-of select="CardOptionDescription" />
          </xsl:element>
          </xsl:element>
          </xsl:when>

          xsl:otherwise
          <xsl:element name="select">
          <xsl:attribute name="name">D2</xsl:attribute>
          <xsl:for-each select="data/record/field1">
          <xsl:element name="option">
          <xsl:attribute name="value">
          <xsl:value-of select="CardLicenceOption"/>
          </xsl:attribute>
          <xsl:value-of select="CardLicenceOptionDescription" />
          </xsl:element>
          </xsl:for-each>
          </xsl:element>
          </xsl:otherwise>
          </xsl:choose>
          </td></tr>
          </xsl:for-each>

          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