 |
| 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
|
|
|
|

August 2nd, 2011, 10:43 AM
|
|
Authorized User
|
|
Join Date: Nov 2010
Posts: 50
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

August 3rd, 2011, 03:22 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
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.
|
|

August 4th, 2011, 10:11 AM
|
|
Authorized User
|
|
Join Date: Nov 2010
Posts: 50
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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.
|
|

August 4th, 2011, 10:32 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
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.
|
|

August 8th, 2011, 11:06 AM
|
|
Authorized User
|
|
Join Date: Nov 2010
Posts: 50
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

August 8th, 2011, 11:10 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
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.
|
|

August 8th, 2011, 11:17 AM
|
|
Authorized User
|
|
Join Date: Nov 2010
Posts: 50
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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>
|
|

August 8th, 2011, 12:20 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
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.
|
|
 |