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. Does anyone know how to access entities from an embedded tag?

Does anyone know how to access entities from an embedded tag?

Scheduled Pinned Locked Moved XML / XSL
xmlquestiontutorialdatabasecom
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
    Mike A Fowler
    wrote on last edited by
    #1

    For example, the person.xml is: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="mystylesheet.xsl"?> <person> <index> <part1> <name>Mike</name> <age>12</age> </part1> <part2> <number>5</number> <string>text</string> </part2> </index> </person> and the .XSL file is: <?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="text" indent="yes"/> <xsl:template match="/person/index/part1"> xsl:textname is </xsl:text> <xsl:value-of select="name"/> xsl:text.</xsl:text> </xsl:template> </xsl:stylesheet> the result is: "name is Mike.5text" how do I get it to read just: "name is Mike"? Why does 5text appear? Thanks! Mike

    M 1 Reply Last reply
    0
    • M Mike A Fowler

      For example, the person.xml is: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="mystylesheet.xsl"?> <person> <index> <part1> <name>Mike</name> <age>12</age> </part1> <part2> <number>5</number> <string>text</string> </part2> </index> </person> and the .XSL file is: <?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="text" indent="yes"/> <xsl:template match="/person/index/part1"> xsl:textname is </xsl:text> <xsl:value-of select="name"/> xsl:text.</xsl:text> </xsl:template> </xsl:stylesheet> the result is: "name is Mike.5text" how do I get it to read just: "name is Mike"? Why does 5text appear? Thanks! Mike

      M Offline
      M Offline
      Mark J Miller
      wrote on last edited by
      #2

      Just add a new xsl:template element to your XSL that matches the root element. Not sure why it works this way, because I've always done it like this. But this should work for you: <?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="text" indent="yes"/> <!-- add this here --> <xsl:template match="/"> <xsl:apply-templates select="/person/index/part1" /> </xsl:template> <!-- end addition --> <xsl:template match="/person/index/part1"> xsl:textname is </xsl:text> <xsl:value-of select="name"/> xsl:text.</xsl:text> </xsl:template> </xsl:stylesheet> My best guess is that you're not telling it what to do with the root "/", so it just includes everything after the match.

      Mark's blog: developMENTALmadness.blogspot.com Funniest variable name: lLongDong - spotted in legacy code, was used to determine how long a beep should be. - Dave Bacher

      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