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. How to ignore tags ?

How to ignore tags ?

Scheduled Pinned Locked Moved XML / XSL
xmlquestionregextutorialannouncement
2 Posts 2 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.
  • M Offline
    M Offline
    matty2desmara
    wrote on last edited by
    #1

    Hello, i have a semi-weird xml file to parse with xsl. The xml has an extra tag which defines what the data is below , how do i go about disregarding anything with ColName in my xsl ? XML <?xml version="1.0" encoding="ISO-8859-1"?> <Report> <ColName> DateTime </ColName> <ColName> PointName </ColName> <ColName> PointValue </ColName> <Record> <Date> data </Date> <Name> data </Name> <Value> data </Value> </Record> <Report> <ColName> DateTime </ColName> <ColName> PointName </ColName> <ColName> PointValue </ColName> <Record> <Date> data </Date> <Name> data </Name> <Value> data </Value> </Record> <Record> <Date> data </Date> <Name> data </Name> <Value> data </Value> </Record> </Report> ``**XSL** `<?xml version="1.0"?> <xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:strip-space elements = "Report"/> <xsl:template match="Record"> <text>&#xD;</text> <xsl:text/><xsl:value-of select="normalize-space(Record)"/><xsl:text/> <xsl:value-of select="normalize-space(DateTime)"/>,<xsl:text/> <xsl:value-of select="normalize-space(PointName)"/>,<xsl:text/> <xsl:value-of select="normalize-space(PointValue)"/>,<xsl:text/> <text>&#xD;</text> <xsl:text disable-output-escaping = "yes" > </xsl:text> </xsl:template> </xsl:stylesheet>` Thanks Matt``

    S 1 Reply Last reply
    0
    • M matty2desmara

      Hello, i have a semi-weird xml file to parse with xsl. The xml has an extra tag which defines what the data is below , how do i go about disregarding anything with ColName in my xsl ? XML <?xml version="1.0" encoding="ISO-8859-1"?> <Report> <ColName> DateTime </ColName> <ColName> PointName </ColName> <ColName> PointValue </ColName> <Record> <Date> data </Date> <Name> data </Name> <Value> data </Value> </Record> <Report> <ColName> DateTime </ColName> <ColName> PointName </ColName> <ColName> PointValue </ColName> <Record> <Date> data </Date> <Name> data </Name> <Value> data </Value> </Record> <Record> <Date> data </Date> <Name> data </Name> <Value> data </Value> </Record> </Report> ``**XSL** `<?xml version="1.0"?> <xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:strip-space elements = "Report"/> <xsl:template match="Record"> <text>&#xD;</text> <xsl:text/><xsl:value-of select="normalize-space(Record)"/><xsl:text/> <xsl:value-of select="normalize-space(DateTime)"/>,<xsl:text/> <xsl:value-of select="normalize-space(PointName)"/>,<xsl:text/> <xsl:value-of select="normalize-space(PointValue)"/>,<xsl:text/> <text>&#xD;</text> <xsl:text disable-output-escaping = "yes" > </xsl:text> </xsl:template> </xsl:stylesheet>` Thanks Matt``

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      matty2desmara wrote:

      how do i go about disregarding anything with ColName in my xsl ?

      I suspect you're running foul of the default behaviour of XSL, which passes through all tags unchanged unless you say otherwise. Add a root element template that just processes what you want, like I've put in here?

      <?xml version="1.0"?>
      <xsl:stylesheet version = "1.0"
      xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="text"/>
      <xsl:strip-space elements = "Report"/>
      <xsl:template match="/">
      <xsl:apply-templates select="//Record"/>
      </xsl:template>

      <xsl:template match="Record">
      <text> </text>
      xsl:text/<xsl:value-of select="normalize-space(Record)"/>xsl:text/
      <xsl:value-of select="normalize-space(DateTime)"/>,xsl:text/
      <xsl:value-of select="normalize-space(PointName)"/>,xsl:text/
      <xsl:value-of select="normalize-space(PointValue)"/>,xsl:text/
      <text> </text>
      <xsl:text disable-output-escaping = "yes" >
      </xsl:text>
      </xsl:template>
      </xsl:stylesheet>

      I'm presuming the use of DateTime, PointTime and PointValue in your XSL is a typo?

      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

      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