|
Subject: RE: [xsl] Problem using document function in a template rule while combining two XML files? From: "Michael Kay" <mhk@xxxxxxxxx> Date: Fri, 31 Oct 2003 10:54:14 -0000 |
You can write
match="qualification"
since there is only one context in which qualification elements appear
in your input.
If both your source documents had the same structure, and you really
needed to write a template rule that matched qualification elements in
one document and not the other, you could do it as:
match="qualification[count((/)|document('doc1.xml'))=0]"
but it's not something I have ever needed to do, and would probably be
rather expensive.
Michael Kay
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
> Narender S chauhan
> Sent: 31 October 2003 04:07
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Cc: Narender S chauhan
> Subject: [xsl] Problem using document function in a template
> rule while combining two XML files?
>
>
> Hi,
> I wanted to make a template rule corresponding to
> apply-templates which makes use of document() function. When
> I try to apply this style sheet on the XML, browser throws an
> error. Am I doing somethin wrong or ... ? Is there any other
> method to achieve the same ? Sample code is:
>
> (Test1.xml)
> <?xml-stylesheet type="text/xsl" href="Test.xsl"?>
> <students>
> <student>
> <name>Naren</name>
> <age>28</age>
> </student>
> <student>
> <name>Vineet</name>
> <age>25</age>
> </student>
> </students>
>
> (Test2.xml)
> <students>
> <student>
> <qualification>Graduate</qualification>
> </student>
> <student>
> <qualification>Post Graduate</qualification>
> </student>
> </students>
>
> (Test.xsl)
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <xsl:output method="html" />
>
> <xsl:variable name="DOC2"
> select="document(Test2.xml)" />
> <xsl:template match="/">
> <html>
> <head>
> <title>Test</title>
> </head>
> <body>
> <xsl:apply-templates
> select="students" />
> </body>
> </html>
> </xsl:template>
>
> <xsl:template match="students">
> <xsl:for-each select="student">
> <xsl:value-of select="name" /> 
> <xsl:value-of select="age" /><br/>
> <xsl:apply-templates
> select="$DOC2/students/student/qualification" />
> </xsl:for-each>
> </xsl:template>
>
> <!-- MSXML throws error at following point that it
> does not allow variables at this position.
> Even if I make use of document function
> directly instead of taking a variable, it still throws an error.
> -->
> <xsl:template
> match="$DOC2/students/student/qualification">
> <span>NAREN</span>
> </xsl:template>
> </xsl:stylesheet>
>
> Any help would be great!
> ~Naren
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Re: Problem using document fu, Dimitre Novatchev | Thread | [xsl] Select statement within HREF, SHEIKH Sajjad |
| [xsl] Re: Re: html table of sorted , Dimitre Novatchev | Date | RE: [xsl] an expression to check if, Michael Kay |
| Month |