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