Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / October 2004

Tip: Looking for answers? Try searching our database.

Adding parent tag by XSLT

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MIB426 - 26 Oct 2004 09:55 GMT
hi
I got
xml file as

<root>

<Question>

<QuestionName>A</QuestionName>

<QuestionNumber>123</QuestionNumber>

</Question>

<Question>

<QuestionName>AA</QuestionName>

<QuestionNumber>123123</QuestionNumber>

</Question>

<Rule>

<RuleName>B</RuleName>

<RuleNumber>456</RuleNumber>

<RuleName>BB</RuleName>

<RuleNumber>456456</RuleNumber>

</Rule>

</root>

then i have xsl file as

<xsl:template match="/">

<Product>

<xsl:apply-templates/>

</Product>

</xsl:template>

<xsl:template match="Question">

<xsl:element name="Question">

<QID>

<xsl:apply-templates select="QuestionName"/>

</QID>

<QNo>

<xsl:apply-templates select="QuestionNumber"/>

</QNo>

</xsl:element>

</xsl:template>

<xsl:template match="Rule">

<xsl:element name="Rule">

<RID>

<xsl:apply-templates select="RuleName"/>

</RID>

<RNo>

<xsl:apply-templates select="RuleNumber"/>

</RNo>

</xsl:element>

</xsl:template>

it gave me result as below:

<Product>

<Question>

<QID>A</QID>

<QNo>123</QNo>

</Question>

<Question>

<QID>AA</QID>

<QNo>123123</QNo>

</Question>

<Rule>

<RID>B</RID>

<RNo>456</RNo>

</Rule>

<Rule>

<RID>BB</RID>

<RNo>456456</RNo>

</Rule>

</Product>

But I would like it turn out like below: (extra QuestionDataset and
RuleDataset tag)

<Product>

<QuestionDataset>

<Question>

<QID>A</QID>

<QNo>123</QNo>

</Question>

<Question>

<QID>AA</QID>

<QNo>123123</QNo>

</Question>

</QuestionDataset>

<RuleDataset>

<Rule>

<RID>B</RID>

<RNo>456</RNo>

</Rule>

<Rule>

<RID>BB</RID>

<RNo>456456</RNo>

</Rule>

</RuleDataset>

</Product>

What i should do on XSLT file??
Thanks
Oleg Tkachenko [MVP] - 26 Oct 2004 11:46 GMT
> But I would like it turn out like below: (extra QuestionDataset and
> RuleDataset tag)

  <xsl:template match="/">
    <Product>
      <QuestionDataset>
        <xsl:apply-templates select="root/Question"/>
      </QuestionDataset>
      <RuleDataset>
        <xsl:apply-templates select="root/Rule"/>
      </RuleDataset>
    </Product>
  </xsl:template>

Signature

Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.