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

November 4th, 2008, 04:44 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
|
|
You can use the value of href attribute, to get the topic (you mean the xml file I think, and also you store xml as dita it seems) name. For more clarifcations, show your xsl codes. That may help much.
------
Rummy
|
|

November 4th, 2008, 08:39 AM
|
|
Authorized User
|
|
Join Date: Oct 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
I forgot to add more line to above.....
7] In html file href should be "filename"
and display text is - <title> inside the actual .dita file.
8] My xsl is now processing either hrefs of topic or on actual dita file.
9] I cant manage to combine those both, using root element match. [they can be combine only in root element]
10] Though i combined both; the code goes to 1000's of line and that also not sufficient/satisfy the conditions.
sorry for not remembering these.
Mahesh
|
|

November 4th, 2008, 11:42 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
|
|
Its better you show the xsl code and the input for that xsl file. Also mention how do you process? whether its thro' any processesor directly or thro' any application? Show required output also.
------
Rummy
|
|

November 7th, 2008, 07:11 AM
|
|
Authorized User
|
|
Join Date: Oct 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
Below is my XML File.
.ditamap
<gsdev_bookmap coursenumber="Test-000-001">
<title>This is for testing purpose</title>
<course_description>
<topicref format="dita" href="course_description\t000.dita" navtitle="This Title is not required. You may not author this one." scope="local" type="gsdev"></topicref>
</course_description>
<course_outline>
<topicref href="t0005.dita" navtitle="Test-000_001 Course Outline"></topicref>
</course_outline>
<frontmatter>
<topicref format="dita" href="frontmatter\t000_FrontMatter.dita" scope="local" type="rcs_concept"></topicref>
</frontmatter>
<module navtitle="Module 00 - Instructor Preface ">
<topicref format="dita" href="module_00\t000_module_00_ModuleIntro.dita" navtitle="INTRO - Instructor Preface" scope="local" type="rcs_moduleintro"></topicref>
<topicref format="dita" href="module_00\t000_Instructor Presentation.dita" navtitle="t2166_Instructor Presentation" scope="local" type="rcs_concept"></topicref>
</module>
<processModule navtitle="Module 01 - Introduction to Some Name">
<topicref format="dita" href="module_intro\t000_module_01_intro.dita" navtitle="INTRO - Introduction to Some Name" scope="local" type="rcs_moduleintro"></topicref>
<topicref format="dita" href="module_01\process_dita\t000_process_concept. dita" navtitle="Some Name" scope="local" type="rcs_concept"></topicref>
<topicref format="dita" href="module_01\process_dita\t000_process_exc01.di ta" navtitle="Some Name" scope="local" type="rcs_exercise"></topicref>
</processModule>
<module navtitle="Module 02 - Some Name">
<topicref format="dita" href="module_intro\t000_module_02_intro.dita" navtitle="INTRO - Some Name" scope="local" type="rcs_moduleintro"></topicref>
<topicref format="dita" href="module_02\Some_Name\Some_Name_dita\concept_S ome_Name.dita" navtitle="CONCEPT - Some Name" scope="local" type="rcs_concept"></topicref>
<topicref format="dita" href="module_02\Some_Name\Some_Name_dita\exer_Some _Name.dita" navtitle="PROCEDURE - Some Name" scope="local" type="rcs_exercise"></topicref>
<topicref format="dita" href="module_02\Some_Name\Some_Name_dita\exerB_Som e_Name.dita" navtitle="EXERCISE - Some Name" scope="local" type="rcs_exercise"></topicref>
</module>
and so on
<backmatter>
<topicref href="backmmater.dita" navtitle="Backmmater"></topicref>
</backmatter>
</gsdev_bookmap>
.dita file
CONCEPT file.
<rcs_concept>
<title>Some Title</title>
....
....
....
</rcs_concept>
.dita file
Exercise file.
<rcs_exercise attribute="A/B">
<title>Procedure / Exercise: Some Title</title>
....
....
....
</rcs_exercise>
Below is XSL File
othercode is removed only required code is mentioned here....
<xsl:template match="gsdev_bookmap">
<div style="margin-left:10pt; margin-right: 10pt; text-indent: 0pt; break-before: page; ">
<p style="font-family: Verdana, Arial, sans-serif; font-size: 18px; font-weight: bold; color: #666666; line-height: 18px; margin-top: 0px; margin-bottom: 3px">Some Text. Some Text. Some Text.</p>
<xsl:for-each select=".">
<xsl:for-each select="//processModule[position() = 1]"><xsl:if test="topicref[@type='rcs_exercise'][1]"><xsl:value-of select=".//topicref[@type='rcs_exercise']/@href" /></xsl:if><xsl:if test="rcs_exercise[1]/title"><xsl:value-of select=".//rcs_exercise/title" /></xsl:if>_</xsl:for-each>
<xsl:for-each select="//module[position() = 1]"><xsl:if test="topicref[@type='rcs_exercise'][1]"><xsl:value-of select=".//topicref[@type='rcs_exercise']/@href" /></xsl:if><xsl:if test="rcs_exercise[1]/title"><xsl:value-of select=".//rcs_exercise/title" />_</xsl:if></xsl:for-each>
<xsl:text disable-output-escaping="yes"><![CDATA[
]]></xsl:text>
<xsl:for-each select="//module[position() = 1]"><xsl:if test="topicref[@type='rcs_exercise'][2]"><xsl:value-of select=".//topicref[@type='rcs_exercise'][2]/@href" /></xsl:if><xsl:if test="rcs_exercise[2]/title"><xsl:value-of select=".//rcs_exercise[2]/title" />_</xsl:if></xsl:for-each>
<xsl:text disable-output-escaping="yes"><![CDATA[
]]></xsl:text>
<xsl:for-each select="//module[position() = 1]"><xsl:if test="topicref[@type='rcs_exercise'][3]"><xsl:value-of select=".//topicref[@type='rcs_exercise'][3]/@href" /></xsl:if><xsl:if test="rcs_exercise[3]/title"><xsl:value-of select=".//rcs_exercise[3]/title" />_</xsl:if></xsl:for-each>
<xsl:text disable-output-escaping="yes"><![CDATA[
]]></xsl:text>
<xsl:for-each select="//module[position() = 1]"><xsl:if test="topicref[@type='rcs_exercise'][4]"><xsl:value-of select=".//topicref[@type='rcs_exercise'][4]/@href" /></xsl:if><xsl:if test="rcs_exercise[4]/title"><xsl:value-of select=".//rcs_exercise[4]/title" />_</xsl:if></xsl:for-each>
<xsl:text disable-output-escaping="yes"><![CDATA[
]]></xsl:text>
and so on.............................
From above i manage to get only Title and Href [Appear as Title_Href (if I tried Href_Title then it should not be happen)]
Here I have to check near about 40 positions for each module position
Though I am not sure that there will be only 40 positions may occur or not?
Also not sure about module?
</xsl:for-each>
</div>
</xsl:template>
Required output
Looks like on html page
This is for testing purpose **** Title Of Course ****
Some Text. Some Text. Some Text.
Module 1. Some Title
1. Procedure: Some Title - I need to get file name of this file; and it should be as <a href=".....">Procedure: Some Title</a> in HTML
Check Your Knowledge
Module 2. Some Title
1. Procedure: Some Title - I need to get file name of this file; and it should be as <a href=".....">Procedure: Some Title</a> in HTML
Check Your Knowledge
Module 3. Some Title
1. Procedure: Some Title - I need to get file name of this file; and it should be as <a href=".....">Procedure: Some Title</a> in HTML
2. Exercise: Some Title - I need to get file name of this file; and it should be as <a href=".....">Exercise: Some Title</a> in HTML
Check Your Knowledge
And So on......
|
|

November 11th, 2008, 05:02 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
|
|
Your explanation is confusing. <xsl:value-of select=".//rcs_exercise[2]/title" /> in your code refers to element rcs_exercise which is not present in your sample xml. The usage of underscore in not correct as per your expectation.
Try this:
<xsl:template match="gsdev_bookmap">
<div>
<p></p>
<xsl:for-each select=".">
<xsl:for-each select="*">
<xsl:for-each select="topicref[@type='rcs_exercise']">
<a><xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute><xsl:value-of select="@navtitle"></xsl:value-of></a>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</div>
</xsl:template>
Post the exact input and its exact required output.
------
Rummy
|
|

November 13th, 2008, 03:43 AM
|
|
Authorized User
|
|
Join Date: Oct 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks Rummy.
Your solution with some manipulations solve my problem.
and I move forward.
Thanks a lot.
But still i am curious
1] Is there any way while processing to get file name using javascript, in xslt 1.0,
if there is no attribute in xml file element;
cant explicit in xslt; etc.
Mahesh
|
|

November 13th, 2008, 04:08 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
|
|
Check the below link. You will get an idea.
http://p2p.wrox.com/topic.asp?TOPIC_ID=7486
------
Rummy
|
|

November 13th, 2008, 06:10 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
>Is there any way while processing to get file name using javascript, in xslt 1.0,
There is no standard way to call javascript from XSLT 1.0, so the answer to this question depends entirely on the XSLT processor you are using.
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
|
|

December 3rd, 2008, 02:22 AM
|
|
Authorized User
|
|
Join Date: Oct 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks to all of you...
RAJ
RUMMY
JOE
And MICHAEL KAY
My problem is solved now, By using counting method.
Thanks again.
Cheers,
Mahesh :)
|
|
 |