Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 2nd, 2011, 10:43 AM
Authorized User
 
Join Date: Nov 2010
Posts: 50
Thanks: 0
Thanked 1 Time in 1 Post
Default xsl link

Hi,

I have xml element X-ref and AFF. i need link for X-Ref element, if i click x-ref element it will show the text for AFF element text. any one can help for the above link

<X-REF REFID="S021848851100709XAF001"></X-REF>
</AUT>
<AFF ID="S021848851100709XAF001">Sample text</AFF>


Regards,
Rockbal
 
Old August 3rd, 2011, 03:22 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

If you want the AFF element with the correct ID then you'd do something like this:

Code:
<xsl:template match="X-REF">
    <xsl:value-of select="//AFF[@Id=current()/@REFID" />
</xsl:template>
How you want to put this into something that responds to a user click depends on what you are using (e..g HTML? Javascript?) which you don't say.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old August 4th, 2011, 10:11 AM
Authorized User
 
Join Date: Nov 2010
Posts: 50
Thanks: 0
Thanked 1 Time in 1 Post
Default

the output format is HTML. I need to show X-REF attribute REFID values and then i click REFID i will show the corresponding AFF text. I used your code it will show error message (//AFF[@Id=current()/@REF ID: expected "]", found "<name>")Kindly Advise.
 
Old August 4th, 2011, 10:32 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Well the error is pretty self explanatory - it says it is missing a ']', so try adding a ']'.

i.e. select="//AFF[@Id=current()/@REFID]"

If you show us the HTML you want to generate we can help you write the XSLT to output it.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old August 8th, 2011, 11:06 AM
Authorized User
 
Join Date: Nov 2010
Posts: 50
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,

I need help for some one.

The below coding i tried but i'm not getting output.

Input file

<a REFID="#A3336C-1920">1. Heading 1</a></p>
<a REFID="#A3336C-1921">2. Heading 2</a></p>
<b ID="A3336C-1920">1. This is Heading One</b>
<b ID="A3336C-1921">2. This is Heading Two</b>


Output

<html>
<p><a id="ch03en01" /><a href="#en01ch03">1. Heading 1</a></p>
<p><a id="ch03en02" /><a href="#en02ch03">2. Heading 2</a></p>
<p><a id="en01ch03" /><a href="#ch03en01">This is Heading One</p></a>
<p><a id="en02ch03" /><a href="#ch03en02">This is Heading Two</p></a>
</html>
Please Kindly look at my input and output file for ur reference. Input is xml and output is html. give me the xsl coding for this occurrence.

Advance Thanks
Rockbal
 
Old August 8th, 2011, 11:10 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

I can't see any relationship between your input and your output. Where does "ch03en01" come from?

Oh, and for an <A> element to link to another element you should use the NAME attribute, not the ID attribute.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old August 8th, 2011, 11:17 AM
Authorized User
 
Join Date: Nov 2010
Posts: 50
Thanks: 0
Thanked 1 Time in 1 Post
Default

Sorry i pasted wrong attribute value. Kindly consider this as input and output.

Input file

<a REFID="ch03en01">1. Heading 1</a></p>
<a REFID="ch03en02">2. Heading 2</a></p>
<b ID="ch03en01">1. This is Heading One</b>
<b ID="ch03en02">2. This is Heading Two</b>


Output

<html>
<p><a id="ch03en01" /><a href="#en01ch03">1. Heading 1</a></p>
<p><a id="ch03en02" /><a href="#en02ch03">2. Heading 2</a></p>
<p><a id="en01ch03" /><a href="#ch03en01">This is Heading One</p></a>
<p><a id="en02ch03" /><a href="#ch03en02">This is Heading Two</p></a>
</html>
 
Old August 8th, 2011, 12:20 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Well, you simply need a template to handle each <a> element, and each <b> element. Then use of the substring() function should allow you to generate the required id.

Code:
<xsl:template match="a">
 <p>
    <a id="{@REFID}"/><a href="#{concat(substring(@REFID,4,3),substring(@REFID,1,3))}"><xsl:value-of select="."/></a>
</p>
</xsl:template>

<xsl:template match="b">
  <p>
      <a id="{concat(substring(@ID,4,3),substring(@ID,1,3))}"/><a href="#{@ID}"><xsl:value-of select="."/></a>
  </p>
</xsl:template>
Hopefully you can finish off the rest.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?





Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl:function pass param to attribute of xsl:instruction bonekrusher XSLT 4 March 31st, 2009 09:06 AM
line number in xml using xsl and html link mrame XSLT 3 June 17th, 2008 01:36 PM
xsl:param and xsl:apply-templates' "select" newbieboobers XSLT 1 March 25th, 2008 07:23 PM
Pass link values as xsl:parameter to php5 then xsl pauljr8 XSLT 1 July 2nd, 2007 10:32 PM
XSL Transform with xsl string NOT xsl file skin XSLT 0 June 16th, 2003 07:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.