473,386 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Help with Extension Objects in XSLT with C# .NET 1.1

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"  
  3.                 xmlns:TP="urn:TemplateParser">
  4. <xsl:template match="/">
  5.   <html>
  6.   <body>
  7.         <h3>DATA Tag Replacement Example</h3>
  8.         <p>
  9.         Name = <b><xsl:value-of select="TP:GetValue('NAME')"/></b>
  10.         </p>
  11.  
  12.         <h3>CONDITION Tag Replacement Example</h3>
  13.         <p>I drive
  14.         <xsl:if test="TP:IsConditionTrue('HONDA')"> an Accord.</xsl:if>
  15.         <xsl:if test="TP:IsConditionTrue('TOYOTA')"> a Camry.</xsl:if>
  16.         </p>
  17.  
  18.         <h3>REPEAT Tag Replacement Example</h3>
  19.         <p>Friends characters...
  20.         <table>
  21.             <tr><th>NAME</th><th>GENDER</th></tr>
  22.             <xsl:for-each select="TP:IsRecordAvailable('Friends')-->
  23.                 <tr>
  24.                     <td><xsl:value-of select="TP:GetRepeatValue('Friends', 'Name')"/></td>
  25.                     <td><xsl:value-of select="TP:GetRepeatValue('Friends', 'Gender')"/></td>
  26.                 </tr>
  27.             </xsl:for-each>
  28.         </table>
  29.         </p>
  30.   </body>
  31.   </html>
  32. </xsl:template>
  33. </xsl:stylesheet>
I have a class named TP that has the methods GetValue(s), GetRepeatValue(s), IsConditionTrue(s) etc implemented.

I am doing a Transform with a dummy XML file (no data), the above XSL file and the TP class like this:

Expand|Select|Wrap|Line Numbers
  1. XPathDocument xmlDoc = new XPathDocument( xmlDocName );
  2. XslTransform xslt = new XslTransform();
  3. xslt.Load( xslDocName );
  4. XsltArgumentList xsltArgList = new XsltArgumentList();
  5. TP tpObj = new TP();
  6. xsltArgList.AddExtensionObject( "urn:TemplateParser", tpObj );
  7. XmlTextWriter writer = new XmlTextWriter( output, null );
  8. xslt.Transform( xmlDoc, xsltArgList, writer, null );
THIS WORKS for the value and if-condition, BUT NOT for the for-each. I am not sure what I need to return from my TP class for the for-each. I tried 1 (true) and 0 (false) but it didn't work.

TIA
Jul 19 '06 #1
1 1361
EDIT:

Instead of a dummy XML file, I replaced the line like this:
Expand|Select|Wrap|Line Numbers
  1. XPathDocument xmlDoc = new XPathDocument( new StringReader( "<doc/>" ) );
FYI the TP class will hold on to any collections and their iterators, and when each "repeat value" is requested for, the corresponding value will be returned. At least that was my idea for the implementation.
Jul 19 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Diego Rivero | last post by:
Hi. I'm working with the XsltTransform class and I found that invocations to extension objects are extremely time consuming in contrast to invocations to embebed code using "msxsl:script"...
4
by: Mark | last post by:
Hi.. I have a c# class that i'm using to implement some extension functions and one of those functions is a simple push/pop stack. I made the c# code fairly generic, taking and returning objects...
1
by: David C. allen | last post by:
I have created a simple Client-side SOAP Extension for a webclass that I have. When I apply the extension attribute to the the calling function in the proxy class I get an error 'Value cannot be...
3
by: WideBoy | last post by:
Hi, I have a software generated schema which creates a few empty elements, e.g. <xsd:sequence/>. I would like to be able to delete these elements from the schema post-generation using XSLT. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.