[daisy] making URL out of field

Todd Wells Todd.Wells at bankserv.com
Thu Jul 10 21:59:08 CEST 2008


I have it working now. The /@valueFormatted  was not needed on the
variable.

Thanks for your help.

Here is the end result.   This Document Styling takes a field with a
given label and turns it into a Link (first removing anything after / in
the field which is a port number on the device the URL points to)

  <xsl:template match="d:fields">
    <xsl:if test="d:field">
      <xsl:if test="d:field">
        <h2>Fields</h2>
        <table class="default">
          <tr>
            <th>Name</th>
            <th>Value</th>
          </tr>
          <xsl:for-each select="d:field">
            <xsl:variable name="isLinkType" select="@valueType =
'link'"/>
        --> <xsl:variable name="isPDU" select="@label='PDU Ports'"/>
             <tr>
              <td style="vertical-align: top"><xsl:value-of
select="@label"/>
                </td>
              <td>
                <xsl:for-each select="*">
                  <xsl:if test="position() > 1"><br/></xsl:if>
                  <xsl:choose>
                    <xsl:when test="$isLinkType">
                      <a href="{@target}">
                        <xsl:value-of select="@valueFormatted"/>
                      </a>
                    </xsl:when>
        -->         <xsl:when test="$isPDU">
        -->           <xsl:variable name="myPDU"
select="substring-before(@valueFormatted,'/')"/>
        -->           <a href="{concat('https://',$myPDU)} ">
        -->             <xsl:value-of select="@valueFormatted"/>
        -->           </a>
        -->         </xsl:when>
                    <xsl:otherwise>
                      <xsl:value-of select="@valueFormatted"/>
                    </xsl:otherwise>
                  </xsl:choose>
                </xsl:for-each>
              </td>
            </tr>
          </xsl:for-each>
  
-----Original Message-----
From: daisy-bounces at lists.cocoondev.org
[mailto:daisy-bounces at lists.cocoondev.org] On Behalf Of Karel Vervaeke
Sent: Wednesday, July 09, 2008 1:52 PM
To: open source CMS - general mailinglist
Subject: Re: [daisy] making URL out of field

Uh sorry, it should be 
href="{concat('http://example.com/',$myVAR1/@valueFormatted)}"

You probably should also wrap urlencode() around the last part

Karel

Todd Wells schreef:
> Thanks, that helps. The <a href line is not working as you specified.
> Here is what I have in the document-style sheet.
>
> <xsl:variable name="myVAR1" select="@valueFormatted"/>
> <a href="concat('http://example.com/',$myVAR1/@valueFormatted) ">
>    <xsl:value-of select="myVAR1"/>
> </a>
>
> When I look at a page using this styling, the link shows as
> http://daisyserver/path/concat(%27http://%27,$myVAR1/@valueFormatted)
>
> instead of http://example.com/xxxxx
>
> The next line <xsl:value-of select="myVAR1"/> correctly displays the
> value of myVAR1
>
> How do you get the concat to be evaluated within the <a href?  I tried
> using a <xsl  tag instead of the concat, but get an error saying you
can
> not use a < inside of an href.
>
>
> -----Original Message-----
> From: daisy-bounces at lists.cocoondev.org
> [mailto:daisy-bounces at lists.cocoondev.org] On Behalf Of Karel Vervaeke
> Sent: Wednesday, July 09, 2008 12:07 AM
> To: Daisy: open source CMS - general mailinglist
> Subject: Re: [daisy] making URL out of field
>
> If I understand your question correctly, you need to create a
> document-styling for your custom document type (see the documentation
> for that)
>
> To generate the url, do something like this:
>
> <xsl:variable name="myField"
> select="d:fields/d:field[@name='MyField']"/>
>
> <a href="concat('http://example.com/foo/bar/',
> $myField/@valueFormatted)">click here</a>
>
> (or replace 'click here' with an xsl:value-of
> select="$myfield/@valueFormatted")
>
> HTH,
> Karel
>
> On Tue, 2008-07-08 at 11:42 -0700, Todd Wells wrote:
>   
>> I have a custom document  type with several text fields.   I would
>> like to make a link in the document using the value in a text field
as
>> part of the URL.
>>
>>  
>>
>> What is the best way to approach this?  
>>
>>
>> _______________________________________________
>> daisy community mailing list
>> Professional Daisy support:
>>     
> http://outerthought.org/en/services/daisy/support.html
>   
>> mail to: daisy at lists.cocoondev.org
>> list information: http://lists.cocoondev.org/mailman/listinfo/daisy
>>     
> _______________________________________________
> daisy community mailing list
> Professional Daisy support:
> http://outerthought.org/en/services/daisy/support.html
> mail to: daisy at lists.cocoondev.org
> list information: http://lists.cocoondev.org/mailman/listinfo/daisy
> _______________________________________________
> daisy community mailing list
> Professional Daisy support:
http://outerthought.org/en/services/daisy/support.html
> mail to: daisy at lists.cocoondev.org
> list information: http://lists.cocoondev.org/mailman/listinfo/daisy
>   

_______________________________________________
daisy community mailing list
Professional Daisy support:
http://outerthought.org/en/services/daisy/support.html
mail to: daisy at lists.cocoondev.org
list information: http://lists.cocoondev.org/mailman/listinfo/daisy


More information about the daisy mailing list