xsl-list
[Top] [All Lists]

RE: linking each item to unique portions in the same page...more than just simple navigation in a document.

2003-06-30 19:30:10
Thanks very much for your help, Jarno.

I want each icon such as textField_1 or textField_1_1 to be linked up to
some correspoding info. at the bottom after all the HSDocumentation has been
displayed.

This is how i want the output HTML to look like:

--------------------------------------------------------------------------

Contract Name: myWebservice
ID: 25_610_15006485306
Start Date: Jun-23-2003

Inputs
        textField_1     <---- these all all links
        integerField_1                  |
        decimalField_1                  |
        dateField_1                             |
        binaryField_1    <------------|
        trueFalseField_1
        DataContainer_1_1
                textField_1_1
                integerField_1_1
                DataContainer_1_1_1
                        textField_1_1_1
                        integerField_1_1_1

Outputs

Settings
        HSUserId                        <------------------  these are all links
        ServiceParameters                                       |
        HSLibName                                               |
        batchStopOnError                                        |
        cost                                                    |
        timeout                 <-----------------|
        locale
        languageCode
        LibURIs
                location
                enableAlternateLocations

Short Description:

The reality, though, is quite different.

Long Description:

VeriSign, which operates much of the Internet's infrastructure, was
processing 600 million domain requests per day in early 2000. It's now
processing nine billion per day. While you were sleeping after 9/11, not
only has the process of technological integration continued, it has actually
intensified ? and this will have profound implications. I recently went out
to Silicon Valley to visit the offices of Google, the world's most popular
search engine.

Input Description:                              <------ new stuff to be
added starts here

Inputs/textField_1
required=true

Inputs/integerField_1
required=false

...

Inputs/DataContainer_1_1
list=true

Inputs/DataContainer_1_1/textField_1_1
required=true

...

Inputs/DataContainer_1_1/DataContainer1_1_1
list=true

Inputs/DataContainer_1_1/DataContainer1_1_1/textField_1_1_1
required=true

.... for all the items.

----------------------------------------------------------------------------
---

If you look at the output, it generates everything but stuff below "Input
Description".

Thanks-

Ahsan

----------------------------------------------------------------------------
-----
XSL:
----------------------------------------------------------------------------
-------

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:template match="HSContract">
    <html>
      <head>
        <title/>
      </head>
      <body>
        <p><a href="#desc"><b>Contract Name: </b><xsl:value-of
select="@contractName"/><br /></a>
                <b>ID: </b><xsl:value-of select="@id"/><br />
                <b>Start Date: </b><xsl:value-of select="@startDate"/><br /></p>
                <xsl:apply-templates select="*"/>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="HSDataContainerType">
    <b><img src="dcopenicon.gif">
    <xsl:value-of select="@name"/></img><br /></b>
    <div style="margin-left: 3em;">
    <xsl:apply-templates select="*"/></div>
  </xsl:template>

  <xsl:template match="*">
        <div><xsl:apply-templates select="HSLink"/></div>
        <div><xsl:apply-templates select="HSDouble"/></div>
        <div><xsl:apply-templates select="HSInteger"/></div>
        <div><xsl:apply-templates select="HSDate"/></div>
        <div><xsl:apply-templates select="HSBinary"/></div>
        <div><xsl:apply-templates select="HSBoolean"/></div>
  </xsl:template>

 <!-- ******************************************************** -->

  <xsl:template name="HSDouble" match="//HSDouble">
        <img src="decimalicon.gif"><xsl:value-of select="@name"/></img><br />
  </xsl:template>

  <xsl:template name="HSInteger" match="//HSInteger">
        <img src="integericon.gif"><xsl:value-of select="@name"/></img><br />
  </xsl:template>

  <xsl:template name="HSDate" match="//HSDataContainerType/HSDate">
        <img src="dateicon.gif"><xsl:value-of select="@name"/></img><br />
  </xsl:template>

  <xsl:template name="HSBinary" match="//HSBinary">
        <img src="binaryicon.gif"><xsl:value-of select="@name"/></img><br />
  </xsl:template>

  <xsl:template name="HSBoolean" match="//HSBoolean">
        <img src="truefalseicon.gif"><xsl:value-of select="@name"/></img><br />
  </xsl:template>

<!--
  <xsl:template name="HSLink" match="//HSString">
        <xsl:for-each select=".">
                <img src="texticon.gif"><a href="#{generate-id(.)}">
                <xsl:value-of select="@name" /></a><br /></img>
        </xsl:for-each>

        <xsl:for-each select=".">Documentation:
                <a name="{generate-id(.)}">
                <xsl:value-of select="@name" /><br />
                <xsl:value-of select="@required" /><br /></a>
        </xsl:for-each>
  </xsl:template>
-->

  <xsl:template name="HSLink" match="//HSString">
        <xsl:for-each select=".">
                <img src="texticon.gif"><a href="#{generate-id(HSString)}">
                <xsl:value-of select="@name" /></a><br /></img>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="*">
    <xsl:for-each select=".">
                <a name="{generate-id(HSString)}">Input Description:<br />
                <xsl:value-of select="@name" />
                <xsl:value-of select="@required" /></a><br />
    </xsl:for-each>
  </xsl:template>

  <!-- ******************************************************** -->

  <xsl:template name="HSDoc" match="HSDocumentation">
        <p><a name="desc"><b>Short Description:</b><br /><br /></a>
        <xsl:apply-templates select="shortDescription" /><br /><br />
        <b>Long Description:</b><br /><br />
        <xsl:apply-templates select="descriptionSection" /></p>
  </xsl:template>

  <xsl:template name="shortDescription" match="//shortDescription">
        <xsl:value-of select="text()"/>
  </xsl:template>

  <xsl:template name= "descriptionSection" match="//descriptionSection">
        <xsl:value-of select="text()"/>
  </xsl:template>

  <!-- ******************************************************** -->

</xsl:stylesheet>

----------------------------------------------------------------------------
-----
INPUT XML:
----------------------------------------------------------------------------
-------

<HSContract contractCategory="2" contractName="myWebservice"
contractType="3" expirationDate="Jun-23-2013" id="25_610_15006485306"
limitMaxConcurrentThreads="false" logEnabled="true" maxConcurrentThreads="2"
revision="25_11" runBatchInParallel="false" startDate="Jun-23-2003">
        <imagePath />
        <HSDataContainerType list="true" name="Inputs" required="true" 
revision=""
systype="true">
                <HSString name="textField_1" required="true" xmlNodeType="1" />
                <HSInteger name="integerField_1" required="true" 
xmlNodeType="1" />
                <HSDouble name="decimalField_1" required="true" xmlNodeType="1" 
/>
                <HSDate isCacheKey="false" name="dateField_1" required="true"
xmlNodeType="1" />
                <HSBinary binaryEncoding="0" name="binaryField_1" 
required="true"
xmlNodeType="1" />
                <HSBoolean name="trueFalseField_1" required="true" 
xmlNodeType="1">
                        <DefaultValue>false</DefaultValue>
                </HSBoolean>
                <HSDataContainerType name="DataContainer_1_1" required="true" 
revision="">
                        <HSString name="textField_1_1" required="true" 
xmlNodeType="1" />
                        <HSInteger name="integerField_1_1" required="true" 
xmlNodeType="1" />
                        <HSDataContainerType name="DataContainer_1_1_1" 
required="true"
revision="">
                                <HSString name="textField_1_1_1" 
required="true" xmlNodeType="1" />
                                <HSInteger name="integerField_1_1_1" 
required="true" xmlNodeType="1" />
                        </HSDataContainerType>
                </HSDataContainerType>
        </HSDataContainerType>
        <HSDataContainerType list="true" name="Outputs" required="true" 
revision=""
systype="true" />
        <HSDataContainerType name="Settings" required="true" revision=""
systype="true">
                <HSString name="HSUserId" systype="true" xmlNodeType="1">
                        <DefaultValue />
                </HSString>
                <HSDataContainerType name="ServiceParameters" 
optionalOrigin="true"
revision="" systype="true" />
                <HSString name="HSLibName" systype="true" xmlNodeType="1">
                        <DefaultValue />
                </HSString>
                <HSBoolean name="batchStopOnError" systype="true" 
xmlNodeType="1">
                        <DefaultValue>true</DefaultValue>
                </HSBoolean>
                <HSDouble name="cost" systype="true" xmlNodeType="1">
                        <DefaultValue>0.0</DefaultValue>
                </HSDouble>
                <HSInteger name="timeout" systype="true" xmlNodeType="1">
                        <DefaultValue>0</DefaultValue>
                </HSInteger>
                <HSString name="locale" systype="true" xmlNodeType="1">
                        <DefaultValue />
                </HSString>
                <HSString name="languageCode" systype="true" xmlNodeType="1">
                        <DefaultValue />
                </HSString>
                <HSDataContainerType name="LibURIs" optionalOrigin="true" 
revision=""
systype="true">
                        <HSString name="location" required="true" 
systype="true" xmlNodeType="1">
                                <DefaultValue />
                        </HSString>
                        <HSBoolean name="enableAlternateLocations" 
required="true" systype="true"
xmlNodeType="1">
                                <DefaultValue>false</DefaultValue>
                        </HSBoolean>
                </HSDataContainerType>
        </HSDataContainerType>
        <HSDocumentation>
                <shortDescription><![CDATA[ The reality, though, is quite 
different. While
you were sleeping after 9/11, not only has the process of technological
integration continued, it has actually intensified ? and this will have
profound implications. I recently went out to Silicon Valley to visit the
offices of Google, the world's most popular search engine. It is a
mind-bending experience. You can actually sit in front of a monitor and
watch a sample of everything that everyone in the world is searching for.
(Hint: sex, God, jobs and, oh my word, professional wrestling usually top
the lists.)
  ]]></shortDescription>
                <descriptionSection title="myWebserviceDesc"><![CDATA[ 
VeriSign, which
operates much of the Internet's infrastructure, was processing 600 million
domain requests per day in early 2000. It's now processing nine billion per
day. A domain request is anytime anyone types in .com or .net. And you ain't
seen nothin' yet. Within the next few years you will be able to be both
mobile and totally connected, thanks to the pending explosion of Wi-Fi, or
wireless fidelity. Using radio technology, Wi-Fi will provide high-speed
connection from your laptop computer or P.D.A. to the Internet from
anywhere ? McDonald's, the beach or your library.

None of this means we, America, just have to do what the world wants, but we
do have to take it seriously, and we do have to be good listeners. We,
America, "have to work even harder to build bridges," argues Mr. Wright,
because info-tech, left to its own devices, will make it so much easier for
small groups to build their own little island kingdoms. And their island
kingdoms, which may not seem important or potent now, will be able to touch
us more, not less.


  ]]></descriptionSection>
                <returnCodeDescription code="" />
        </HSDocumentation>
</HSContract>
----------------------------------------------------------------------------
--------


-----Original Message-----
From: Jarno(_dot_)Elovirta(_at_)nokia(_dot_)com 
[mailto:Jarno(_dot_)Elovirta(_at_)nokia(_dot_)com]
Sent: Monday, June 30, 2003 1:18 AM
To: ahsan_hussain(_at_)nextaxiom(_dot_)com
Subject: RE: linking each item to unique portions in the same
page...more than just simple navigation in a document.


Hi,

Haven't got too much time to get into off-list consulting.

Attached below are the XML and the XSL files i wrote. Is
there a way to make
each correspoding field point to a description at the bottom.
For example,

Point to a description? Do you mean creating a link from the field to the
description?

the textField_1 should be a link to a unique description below or the
textField_1_1 should point to its own description. Since i use
apply-templates for each textField or decimalField etc., i
seem to have
trouble coming up with sepate links for textField_1 and textField1_1.

Isn't the name enough? "textField_1" and "textField1_1" are different ids.
You can use generate-id() to generate unique identifiers.

A good example for what i want to do is to look at the "Contract Name:
myWebservice" link in the output (HTML). When i click on it,
it takes me to
short description section. I know how to work the html for
that but what i
am confused about is that how would i be able to have
separate links to all
items. For e.g I use:
<xsl:template name="HSString" match="//HSDataContainerType/HSString">

You should rewrite the match pattern to "HSDataContainerType/HSString", the
leading // is redundant.

      <img src="texticon.gif"><xsl:value-of
select="@name"/></img><br />
  </xsl:template>
to process all HSStrings. They could be textField_1 or
textField_1_1. How do
i link each of them to unique portions in my code.

Where's the link target? I don't understand how you're supposed to like to
another part of your document without the link target.

  <xsl:template match="*">
    <div><xsl:apply-templates select="HSString"/></div>
      <div><xsl:apply-templates select="HSDouble"/></div>
      <div><xsl:apply-templates select="HSInteger"/></div>
      <div><xsl:apply-templates select="HSDate"/></div>
      <div><xsl:apply-templates select="HSBinary"/></div>
      <div><xsl:apply-templates select="HSBoolean"/></div>
  </xsl:template>

Is the order significant here? If it's not, rewrite this to

  <xsl:for-each select="*">
    <div>
      <xsl:apply-templates select="."/>
    </div
  </xsl:for-each>

for brevity and clarity.

   <xsl:template name="HSString"
match="//HSDataContainerType/HSString">
      <img src="texticon.gif"><xsl:value-of
select="@name"/></img><br />
  </xsl:template>

  <xsl:template name="HSDouble"
match="//HSDataContainerType/HSDouble">
      <img src="decimalicon.gif"><xsl:value-of
select="@name"/></img><br />
  </xsl:template>

  <xsl:template name="HSInteger"
match="//HSDataContainerType/HSInteger">
      <img src="integericon.gif"><xsl:value-of
select="@name"/></img><br />
  </xsl:template>

  <xsl:template name="HSDate" match="//HSDataContainerType/HSDate">
      <img src="dateicon.gif"><xsl:value-of
select="@name"/></img><br />
  </xsl:template>

  <xsl:template name="HSBinary"
match="//HSDataContainerType/HSBinary">
      <img src="binaryicon.gif"><xsl:value-of
select="@name"/></img><br />
  </xsl:template>

  <xsl:template name="HSBoolean"
match="//HSDataContainerType/HSBoolean">
      <img src="truefalseicon.gif"><xsl:value-of
select="@name"/></img><br />
  </xsl:template>

Again, you could rewrite these templates to

  <xsl:template match="HSSString | HSDouble | HSInteger | HSDate | HSBinary
| HSBoolean">
    <img>
      <xsl:attribute name="src">
        <xsl:choose>
          <xsl:when test="self::HSSString">texticon</xsl:when>
          <xsl:when test="self::HSDouble">decimalicon</xsl:when>
          <xsl:when test="self::HSInteger">integericon</xsl:when>
          <xsl:when test="self::HSDate">dateicon</xsl:when>
          <xsl:when test="self::HSBinary">binaryicon</xsl:when>
          <xsl:when test="self::HSBoolean">truefalseicon</xsl:when>
        </xsl:choose>
        <xsl:text>.gif</xsl:text>
      </xsl:attribute>
      <xsl:value-of select="@name"/>
    </img>
    <br/>
  </xsl:template>

for clarity.

Cheers,

Jarno


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>