Lifelesspeople.com

 Forum FAQsForum FAQs  Knowledge BaseKnowledge Base  RulesRules   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   HostingHosting   RegisterRegister 
 DonateDonate   WikiWiki   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

XSLT Question: How can I get an element tag name list?

 
Lifelesspeople.com Forum Index -> Web Architects' Abode
Post new topic   Reply to topic View previous topic :: View next topic  
Author Message
kutar
Mini Game Hunter


Joined: 03 Jun 2004
Posts: 1327
Location: Techno Island

PostPosted: Tue Mar 18, 2008 1:13 am    Post subject: XSLT Question: How can I get an element tag name list? Reply with quote

I want to an xml inspector to do some statistic based on element tag name...

The book was talked about the method of doing math, but not many people taking about get a tag name list (they preferring process all the node/process the xml with known schema - not exlporing or inspecting xml)

Does anyone have good reference or have a xslt stylesheet for the xml inspectin purpose or xslt can give me a list of all element tag name?

thank you.
_________________
Sleepless Cat‧The one looking for her path...
Back to top
 
LP-SolidRaven
Dictator of the Dump


Joined: 06 Jun 2004
Posts: 7015
Location: The cheese is made out of moon

PostPosted: Tue Mar 18, 2008 5:42 am    Post subject: Reply with quote

You can always check the W3 website. You can be pretty sure all possible tags are listed there. You can find the one for XSLT 1 here.
_________________
Quote:

<bart416> I just realized something
<bart416> we celebrate the fact that this piece of rock made one rotation around a glowing ball of plasma that is kept together due to its own gravity well
<njsg> HAPPY NEW YEAR
<Easter> ^^
Back to top
 
exsanguination
Forum Regular


Joined: 27 Apr 2005
Posts: 412
Location: Australia

PostPosted: Tue Mar 18, 2008 4:40 pm    Post subject: Re: XSLT Question: How can I get an element tag name list? Reply with quote

kutar wrote:
I want to an xml inspector to do some statistic based on element tag name...

The book was talked about the method of doing math, but not many people taking about get a tag name list (they preferring process all the node/process the xml with known schema - not exlporing or inspecting xml)

Does anyone have good reference or have a xslt stylesheet for the xml inspectin purpose or xslt can give me a list of all element tag name?

thank you.


This is really simple and you should be able to do it (if not go back to the start of your book Wink)....I'm not going to give you code yet - if you don't have a solution in a week, then ill post an example.

So lets just think about what you need to do...you need a template that will match any element (or node) and output the name of that element.

Do you get what I'm hinting at?

http://www.zvon.org/xxl/XSLTreference/Output/
Back to top
 
krt
...


Joined: 11 Jan 2005
Posts: 4607
Location: Australia

PostPosted: Sun Mar 23, 2008 6:23 am    Post subject: Reply with quote

He wants a list of tags for the specific XML document, not the tags available for XSL stylesheets.

kutar, you didn't seem to explain much about what you want or your intent. For all I know, this could be all you are after...
Code:
<xsl:template match="*">
  <xsl:text><xsl:value-of select="name()"><br /></xsl:text>
</xsl:template>

(maybe with some sprucing up or with a counter)

How about some sample input and desired output?
Back to top
 
LP-SolidRaven
Dictator of the Dump


Joined: 06 Jun 2004
Posts: 7015
Location: The cheese is made out of moon

PostPosted: Sun Mar 23, 2008 10:49 am    Post subject: Reply with quote

krt wrote:
He wants a list of tags for the specific XML document, not the tags available for XSL stylesheets.

Uhm, if you read that entire document there's a big change you'll know how to do it. Specifications are rather detailed...
_________________
Quote:

<bart416> I just realized something
<bart416> we celebrate the fact that this piece of rock made one rotation around a glowing ball of plasma that is kept together due to its own gravity well
<njsg> HAPPY NEW YEAR
<Easter> ^^
Back to top
 
exsanguination
Forum Regular


Joined: 27 Apr 2005
Posts: 412
Location: Australia

PostPosted: Tue Mar 25, 2008 8:50 pm    Post subject: Reply with quote

krt wrote:
He wants a list of tags for the specific XML document, not the tags available for XSL stylesheets.

kutar, you didn't seem to explain much about what you want or your intent. For all I know, this could be all you are after...
Code:
<xsl:template match="*">
  <xsl:text><xsl:value-of select="name()"><br /></xsl:text>
</xsl:template>

(maybe with some sprucing up or with a counter)

How about some sample input and desired output?


Yeah thats the basic idea...

But there is a slight trick...you need a specific template to match on text(), be cause text() is a type of node() you would also pick up the text in non empty elements as a node.

Code:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output encoding="UTF-8" indent="yes" version="1.0" method="xml" />
   <xsl:template match="/">
      <ElementList>
         <xsl:apply-templates />
      </ElementList>
   </xsl:template>
   <xsl:template match="node()">
      <Element Name="{name()}" />
      <xsl:apply-templates />
   </xsl:template>
   <xsl:template match="text() | @* | comment()" />
</xsl:stylesheet>
Back to top
 
Display posts from previous:   
Post new topic   Reply to topic    Lifelesspeople.com Forum Index -> Web Architects' Abode All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Home | Hosting | News | Forum | Links | System Status | About | Archive | Donate ]
Powered by phpBB © 2001, 2002 phpBB Group
All trademarks and copyrights on this page are owned by their respective owners. Posts and comments are owned by the poster. Everything else © 2001 - 2007 Lifelesspeople.com