Re: [xslt] Beginner XSLT/xsltproc question.



The trick is that you used a NameSpace URI in your xml file
(http://oval.mitre.org/XMLSchema/oval).
You may say that the real hierarchy is:
oval:oval-->oval:definitions-->oval:definition

To make it work, you need to match the nodes with the same namespace URI, and you defined a prefix
to associate with this URI named oval. Thus you need to use something like:

<xsl:for-each select="oval:definition">



--- sudhakar+xslt CS Princeton EDU wrote:

> 
> 
> Hi all,
> 
> 	I am a newbie for XML/XSLT/xlstproc.  I am running into trouble
> with my first program. I will be glad if someone can help me write the
> XSLT file.  I read http://www.w3.org/TR/xslt .  But I am missing
> something.
> 
> 	This is the node hierarchy:
> 
> 	oval-->definitions-->definition.
> 
> 	For some reason, I am not able to write a for-each rule to select
> the "definition" nodes.  The following code ilustrates the problem I am
> running into.
> 
> <xsl:template name="definitions">
> 		Node name is
> 		<xsl:value-of select="name()"/>
> 		<xsl:call-template name="newline"/>
> 
> 		<!-- This does *not* work. Why? -->
> 		<xsl:for-each select="definition">
> 			DEFINITION node
> 			<xsl:value-of select="name()"/>
> 			<xsl:call-template name="newline"/>
> 		</xsl:for-each>
> 
> 		<!-- This works -->
> 		<xsl:for-each select="*">
> 			STAR node
> 			<xsl:value-of select="name()"/>
> 			<xsl:call-template name="newline"/>
> 		</xsl:for-each>
> </xsl:template>
> 
> 
> The output is:
> 
> Node name is definitions
> STAR node definition
> 
> 
> I would have expected the xsltproc to print "DEFINITION node" too.
> 
> 
> Am I missing something?    The complete files can found here:
> 
> style sheet:
> http://www.cs.princeton.edu/~sudhakar/scratch/xml/gnome/new.xsl
> 
> XML file:
> http://www.cs.princeton.edu/~sudhakar/scratch/xml/gnome/small-redhat.definitions.xml
> 
> output:
> http://www.cs.princeton.edu/~sudhakar/scratch/xml/gnome/output.html
> 
> 
> thanks in advance,
> Sudhakar.
> 
> 
> 22:12:12]opus::~/p/xml/gnome $ xsltproc -V
> Using libxml 20510, libxslt 10033 and libexslt 722
> xsltproc was compiled against libxml 20510, libxslt 10033 and libexslt 722
> libxslt 10033 was compiled against libxml 20510
> libexslt 722 was compiled against libxml 20510
> [22:12:15]opus::~/p/xml/gnome $
> 
> Command line used:
> xsltproc  --output output.html  new.xsl    small-redhat.definitions.xml
> 
> 
> 
> 
> 
> 
> 
> Sudhakar Govindavajhala	                  Department of Computer Science
> Graduate Student,                         Princeton University
> Ph : (lab) +1 609 258 1763                   (office) +1 609 258 1798
>                http://www.cs.princeton.edu/~sudhakar
> _______________________________________________
> xslt mailing list, project page http://xmlsoft.org/XSLT/
> xslt gnome org
> http://mail.gnome.org/mailman/listinfo/xslt
> 


=====
Marian
http://www.utdallas.edu/~mgo031000/


		
__________________________________ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail SpamGuard. 
http://promotions.yahoo.com/new_mail 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]