Click here to Skip to main content
14,422,081 members
   

XML / XSL

 
QuestionSearching for multiple types with XPath Pin
Trollslayer10-Jul-10 1:45
mentorTrollslayer10-Jul-10 1:45 
AnswerRe: Searching for multiple types with XPath Pin
Not Active10-Jul-10 8:06
mentorNot Active10-Jul-10 8:06 
AnswerRe: Searching for multiple types with XPath Pin
sameerazazi877-Aug-10 3:07
Membersameerazazi877-Aug-10 3:07 
QuestionXpath problem Pin
snehasish9-Jul-10 1:27
Membersnehasish9-Jul-10 1:27 
AnswerRe: Xpath problem Pin
Stuart Dootson9-Jul-10 12:12
professionalStuart Dootson9-Jul-10 12:12 
QuestionExcel to XML conversion Pin
priyaahh5-Jul-10 19:49
Memberpriyaahh5-Jul-10 19:49 
AnswerRe: Excel to XML conversion Pin
evd4610-Aug-10 21:13
Memberevd4610-Aug-10 21:13 
Questionxsl:apply-templates help please! [modified] Pin
Neophyte301-Jul-10 5:49
MemberNeophyte301-Jul-10 5:49 
I am attempting to digest someone elses xml - which is why I can't just reformat it as I'd like. I think that applying templates (possibly nested) is the way to go, but I'm buggered if I can see how to do it properly - the w3schools site covers the basics, but not what I'm after. Can anyone a) solve my problem or b) point me to somewhere I can find a more in-depth explanation?

I'd even settle for c) "XSLT does not work that way!"

Source XML:
<Beds>
<Single>
	<Base>1</Base>
	<BaseCode>BER</BaseCode>
	<Mattress>2</Mattress>
	<MattressCode>BER</MattressCode>
	<Headboard>3</Headboard>
	<HeadboardCode>BER</HeadboardCode>
</Single>
<Double>
	<Base>0</Base>
	<BaseCode></BaseCode>
	<Mattress>1</Mattress>
	<MattressCode>BER</MattressCode>
	<Headboard>2</Headboard>
	<HeadboardCode>TBD</HeadboardCode>
</Double>
<King>
	<Base></Base>
	<BaseCode></BaseCode>
	<Mattress></Mattress>
	<MattressCode></MattressCode>
	<Headboard></Headboard>
	<HeadboardCode></HeadboardCode>
</King>
<Sofa>
	<Foam>5</Foam>
	<FoamCode>BER</FoamCode>
	<Metal></Metal>
	<MetalCode></MetalCode>
</Sofa>
</Beds>


Desired Output XML:
<Row>
	<Description>SingleBase</Description>
	<Value>BER</Value>
	<Quantity>1</Quantity>
</Row>
<Row>
	<Description>SingleMattress</Description>
	<Value>BER</Value>
	<Quantity>2</Quantity>
</Row>
<Row>
	<Description>SingleHeadboard</Description>
	<Value>BER</Value>
	<Quantity>3</Quantity>
</Row>
<Row>
	<Description>DoubleMattress</Description>
	<Value>BER</Value>
	<Quantity>1</Quantity>
</Row>
<Row>
	<Description>DoubleHeadboard</Description>
	<Value>BER</Value>
	<Quantity>2</Quantity>
</Row>
<Row>
	<Description>SofaFoam</Description>
	<Value>BER</Value>
	<Quantity>5</Quantity>
</Row>


I thought I'd start with:

<xsl:for-each select="Beds">
          <Row>
            <xsl:apply-templates></xsl:apply-templates>
          </Row>
          
        </xsl:for-each>


but now I'm stuck as to how to access the nodename of the current node... Or whether to wrap in a choose (if that's even possible?)...

modified on Thursday, July 1, 2010 11:41 AM

AnswerRe: xsl:apply-templates help please! Pin
Neophyte305-Jul-10 1:17
MemberNeophyte305-Jul-10 1:17 
GeneralRe: xsl:apply-templates help please! Pin
Stuart Dootson6-Jul-10 5:37
professionalStuart Dootson6-Jul-10 5:37 
AnswerRe: xsl:apply-templates help please! Pin
Stuart Dootson6-Jul-10 5:14
professionalStuart Dootson6-Jul-10 5:14 
GeneralRe: xsl:apply-templates help please! Pin
Neophyte306-Jul-10 6:47
MemberNeophyte306-Jul-10 6:47 
GeneralRe: xsl:apply-templates help please! Pin
Stuart Dootson6-Jul-10 15:38
professionalStuart Dootson6-Jul-10 15:38 
QuestionHow to upload an Xml Schema to my ftp server and have Visual Studio provide intellisense for it? Pin
WebMaster1-Jul-10 3:07
MemberWebMaster1-Jul-10 3:07 
AnswerRe: How to upload an Xml Schema to my ftp server and have Visual Studio provide intellisense for it? Pin
Not Active1-Jul-10 3:38
mentorNot Active1-Jul-10 3:38 
GeneralRe: How to upload an Xml Schema to my ftp server and have Visual Studio provide intellisense for it? Pin
WebMaster1-Jul-10 4:11
MemberWebMaster1-Jul-10 4:11 
Questiontransformed cdata content not escaping properly (or atleast the way i want it it) Pin
nyhtal30-Jun-10 20:59
Membernyhtal30-Jun-10 20:59 
QuestionVXML Pin
muka6629-Jun-10 5:15
Membermuka6629-Jun-10 5:15 
QuestionHow to create xmpp client using C#? Pin
manjeeet18-Jun-10 0:13
Membermanjeeet18-Jun-10 0:13 
Answercross-post Pin
Luc Pattyn18-Jun-10 3:27
sitebuilderLuc Pattyn18-Jun-10 3:27 
QuestionError in running ASP.NET C# (MySql) site Pin
Dot-Net-Dev16-Jun-10 18:24
MemberDot-Net-Dev16-Jun-10 18:24 
QuestionBeginner help to tag Bold text in DocBook v5 for XML export [modified] Pin
keeta116-Jun-10 13:06
Memberkeeta116-Jun-10 13:06 
QuestionWrite XSL for this xml i want to convert xml to CSV formt Pin
ksanju100012-Jun-10 10:14
Memberksanju100012-Jun-10 10:14 
AnswerRe: Write XSL for this xml i want to convert xml to CSV formt Pin
SeMartens15-Jun-10 22:10
MemberSeMartens15-Jun-10 22:10 
Questionwriting to xml file Pin
Farraj8-Jun-10 18:17
MemberFarraj8-Jun-10 18:17 

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.