Click here to Skip to main content
15,892,298 members
Home / Discussions / XML / XSL
   

XML / XSL

 
AnswerRe: Help with assignment question please! Pin
Mike Burroughs12-Jan-06 14:57
Mike Burroughs12-Jan-06 14:57 
GeneralRe: Help with assignment question please! Pin
R0ssini13-Jan-06 14:53
R0ssini13-Jan-06 14:53 
QuestionProblem with xslt. Pin
Chetan Ranpariya5-Jan-06 18:54
Chetan Ranpariya5-Jan-06 18:54 
QuestionInsert string to Bitmap path? Pin
SpeBeeTo5-Jan-06 14:03
SpeBeeTo5-Jan-06 14:03 
AnswerRe: Insert string to Bitmap path? Pin
Curtis Schlak.6-Jan-06 7:31
Curtis Schlak.6-Jan-06 7:31 
GeneralRe: Insert string to Bitmap path? Pin
SpeBeeTo6-Jan-06 19:37
SpeBeeTo6-Jan-06 19:37 
QuestionGrouping different wordml paragraph styles under one parent node in xml Pin
gandhiaryah4-Jan-06 5:27
gandhiaryah4-Jan-06 5:27 
QuestionUsing Two "group-adjacent" Pin
gandhiaryah4-Jan-06 2:36
gandhiaryah4-Jan-06 2:36 
Input XML:
---------
<artbody>
<section id="s1">
<heading1 level="1">INTRODUCTION</heading1>
<para>xxx <b>xxx</b> xxxxxxxxxxxxxxxxxxx</para>

<subsect id="s1-1">
<heading2 level="2">Linkends</heading2>
<para>This paragraph contains fixed figure &lt;fx1&gt;, &lt;fx2&gt;, &lt;fx3&gt;.</para>
<para>This paragraph contains linkend type for Bibliography (numbered) (type=bib): [<link type="bib" linkend="">3</link>], [<link type="bib" linkend="">4, 7</link>], [<link type="bib" linkend="">7–12</link>], [<link type="bib" linkend="">14-18</link>], [<link type="bib" linkend="">3, 5, 7–12</link>] and [<link type="bib" linkend="">6, 8, 15-17</link>].</para></subsect1>

<subsect1 id="s1-5-1">
<heading3 level="3">Question and Answer</heading3>
<quest>What's you name?</quest>
<answer>Pradeep</answer>
<quest>How old are you?</quest>
<answer>62</answer>
<quest>So, what are you doing now?</quest>
<answer>Just chatting with an idiot</answer> </subsect>
</subsect>


<subsect1 id="s1-5-1">
<heading3 level="3">poem</heading3>
<stanza></b>What's you name?<b></stanza>
<stanza></b>Pradeep<b></stanza>
</subsect>


<para>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</para>
<para>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</para>
</section>
</artbody>

Style Sheet:
-----------

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint"
xmlnsBlush | :O ="urn:schemas-microsoft-com:office:office"
exclude-result-prefixes="aml w wx o v">

<xsl:output method="xml"
indent="yes"
omit-xml-declaration="yes"/>

<xsl:strip-space elements="*"/>
<xsl:template match="*">
<xsl:choose>
<xsl:when test="artbody">
<xsl:copy>
<xsl:for-each-group select="child::node()" group-adjacent="self::quest or self::answer">
<xsl:choose>
<xsl:when test="current-grouping-key()">
<b> <quanta></b>
<xsl:apply-templates select="current-group()"/>

</quanta>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="current-group()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</xsl:copy>

</xsl:template>
</xsl:stylesheet>

Questions:
---------

1. I would like to group 'quest' & 'answer' under 'qanda'
2. I would like to group 'stanza' under 'poem'

I want to read each element dynamically and should group the orphan nodes such as quest & stanza under another parent element. But, with your suggestion, I could group one at a time. I couldn't do it in a loop. When I tried, I am getting duplicate of orphan nodes and all the attribute values are discarded.

If you could help us to design a xslt that groups "quest & answer" and "stanza" dynamically and retains all other elements untouched.

I sincerely appreciate your help in this regard.Confused | :confused:

Thanks & Regards,
-Rocxy
Questiondirecting to a root directory in xml Pin
SpeBeeTo3-Jan-06 12:09
SpeBeeTo3-Jan-06 12:09 
AnswerRe: directing to a root directory in xml Pin
Curtis Schlak.3-Jan-06 12:14
Curtis Schlak.3-Jan-06 12:14 
QuestionConver XML data To Excelsheet Pin
Chetan Ranpariya2-Jan-06 17:43
Chetan Ranpariya2-Jan-06 17:43 
QuestionGrouping XML Elements using XSLT Pin
gandhiaryah28-Dec-05 19:57
gandhiaryah28-Dec-05 19:57 
AnswerRe: Grouping XML Elements using XSLT Pin
Michael Flanakin29-Dec-05 3:54
Michael Flanakin29-Dec-05 3:54 
Questionstoring xml file in sql using asp Pin
suneelbabu_net27-Dec-05 16:03
suneelbabu_net27-Dec-05 16:03 
Questionhow to create instance after passing class type to function Pin
Michael Lev26-Dec-05 9:33
Michael Lev26-Dec-05 9:33 
QuestionMSXML 0xC00000FD stack overflow Pin
agent_hunt26-Dec-05 1:06
agent_hunt26-Dec-05 1:06 
QuestionHow to Get the Value when we specify the name .. Pin
zxc8925-Dec-05 19:35
zxc8925-Dec-05 19:35 
Questionimage compression project Pin
Femi Buroh25-Dec-05 10:17
Femi Buroh25-Dec-05 10:17 
Questionextracting data from xml and loading into dataset Pin
wpcolleen20-Dec-05 1:31
wpcolleen20-Dec-05 1:31 
QuestionEasy JPG question! Pin
SpeBeeTo19-Dec-05 9:38
SpeBeeTo19-Dec-05 9:38 
AnswerRe: Easy JPG question! Pin
Michael Flanakin29-Dec-05 3:58
Michael Flanakin29-Dec-05 3:58 
GeneralRe: Easy JPG question! Pin
SpeBeeTo30-Dec-05 15:08
SpeBeeTo30-Dec-05 15:08 
QuestionTrouble using sql:relation/sql:relationship in xsd file ... Pin
cmacgowan19-Dec-05 9:17
cmacgowan19-Dec-05 9:17 
QuestionXPath expression Pin
Andy H14-Dec-05 22:37
Andy H14-Dec-05 22:37 
AnswerRe: XPath expression Pin
Stuart Dootson15-Dec-05 7:26
professionalStuart Dootson15-Dec-05 7:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.