Need Help making Custom Tags for sandcastle

Sep 11, 2008 at 10:52 PM
Hi

I been following this tutorial Custom Tags and been able to do what they did in the tutorial to work.

However the tutorial only goes into tags that don't have any attributes in them. I want to make some tags that have attributes in them but I can't figure out how.

So I want to make this tag:

<authors id="123" email="32@hotmail.com">chobo2</authors>

How could I make this.

I know there are prebuild tags like the parm tag that has attributes but I can't seem to get that result.
Sep 11, 2008 at 11:10 PM
>>chobo2: I know there are prebuild tags like the parm tag that has attributes but I can't seem to get that result.
The tutorial assumes you have a working knowledge of the XSL, which you will need if you want to transform your
custom tags to an HTML output.

The tutorial is not restricted to tags without attributes, so please read a little bit on XSL, it is easy and simple to understand.
If, however, the above is the only custom tag you want to use, then show how you want it formatted and we could help you.

Best regards,
Paul.
Sep 11, 2008 at 11:21 PM
It's been a while since I used xsl and I really don't have time(this is just a nice to have and not required for my current project).

If you could make this quickly that would be great it also would give me a model to make other ones if I needed too.

I was just thinking off

///<summary>stuff here </summary>
///<remarks>
/// <author id="123" email="32@hotmail.com">chobo2</author>
///</remakrs>

So that would be what I would be placing it. Other then that in teh document it would be cool that the people would know they are looking at an Author of the code. Id is the student number and email.
Sep 11, 2008 at 11:27 PM
>>chobo2: So that would be what I would be placing it.
How do you want this to be formatted or how do you want this to appear in the output?

Best regards,
Paul.
Sep 12, 2008 at 12:31 AM
Hi, 

Use the XPath attribute (@) syntax.
<xsl:template match="author">

  ID: <font size="3">
      <xsl:value-of select="@id"/></font>

  Email: <font size="3">
      <xsl:value-of select="@email"/></font>

</xsl:template>
- Dave
Sep 12, 2008 at 6:47 AM
"How do you want this to be formatted or how do you want this to appear in the output?

Best regards,
Paul."

Something how davedev has it.

Output would be like

Author: chobo2
ID: 105195915
email: 2415@hotmail.com

I tried to implement what davedev did but I am not sure if I did something wrong I stuck it main_sandcastle.xsl(prototype one) I was not really sure where to put it so I just stuck it near the other ones(like return).

I then tried to use SandCastle Help file builder to build it but I don't see any either the ID or Email tags.
Sep 12, 2008 at 7:15 AM
Hi,

You just need to place the xsl:template element as a child of the xsl:stylesheet element in main_sandcastle.xsl.  As you pointed out, next to the template that matches return, or any other XML documentation element, should be fine.

A basic template for what you want might look like this: 

<xsl:template match="author">

  Author: <xsl:value-of select="."/>
  <br/>
  ID: <xsl:value-of select="@id"/>
  <br/>
  Email: <xsl:value-of select="@email"/>

</xsl:template>

Make sure that you're adding it to the appropriate presentation style.  I'm not sure, but there may be something else that you need to do to get it working in SHFB.  In plain old Sandcastle though, simply adding the template should be enough.

- Dave
Editor
Sep 12, 2008 at 3:59 PM
SHFB doesn't override the transformations so as long as it's in the right place, it will work.

Eric
Sep 13, 2008 at 4:11 AM
Thanks all this worked great. It also gives me a great base to work off. Anything similar and I should be able to make it. SandCastle is so cool in this way and when I have more time I am going to learn some more xslt so I can make more tags.

Or hopefully someone will have made a tool that add's custom comments to sandcastle.

One more thing.

How would I make a if statement so that if there is more then one author tag it would put a break after first set of information is done?
Sep 13, 2008 at 6:10 AM
Edited Sep 13, 2008 at 6:12 AM

Hi,

Try something like this:

<!-- existing template stuff here -->

<xsl:if test="generate-id(.) != generate-id(..//author[last()])">
    <
br/><br/>
</
xsl:if>

This can produce results such as: 

  Billy<br /><br />
  Pam<br /><br />
  Roger<br /><br />
  Joe 

- Dave