The moose likes XML and Related Technologies and the fly likes How to get the sibling node just after the context Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "How to get the sibling node just after the context" Watch "How to get the sibling node just after the context" New topic
Author

How to get the sibling node just after the context

abha jain
Greenhorn

Joined: Nov 16, 2011
Posts: 2
Hi,

I am transforming one xml file into another using xslt.
I have sample of xml file also:

<table:table-row>
<table:table-cell table:style-name="Title.A1" office:value-type="string" table:protected="true">
<text:p text:style-name="NEESTitle">Article Title</text:p>
</table:table-cell>
<table:table-cell table:style-name="Title.B1" office:value-type="string">
<text:p text:style-name="P4">Wipro Technology</text:p>
</table:table-cell>
</table:table-row>


Now I want Wipro Technology under <Title> tag.
I can fetch the value of Article Title because that is associated with a style name(attribute). Now I just want to take next node value.
Following is the sample code to get the value of Article Title:

<xsl:template match="/">
<Article>
<xsl:choose>
<xsl:when test="office:document-content/office:body/
office:text/table:table/table:table-row/table:table-cell/text:p[@text:style-name='NEESTitle']">
<xsl:variable name="title" select="office:document-content/office:body/
office:text/table:table/table:table-row/table:table-cell/text:p[@text:style-name='NEESTitle']"/>
<xsl:message> title value is from table <xsl:value-of select="$title"/></xsl:message>
<Article_Title>
<xsl:value-of select="$title"/>
</Article_Title>
</xsl:when>
</Article>
</xsl:template>



Please help me to get that.


Rob Spoor
Saloon Keeper

Joined: Oct 27, 2005
Posts: 18368

I'll move this thread to our XML forum.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 225
This.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 26716
And welcome to the Ranch
abha jain
Greenhorn

Joined: Nov 16, 2011
Posts: 2
Thank you... It worked
 
 
subject: How to get the sibling node just after the context
 
Threads others viewed
Newbie Question---Help?
Using double slash(//) while using XSLT
Getting my HTML output to backspace one character
XSL to html conversion
XSL: cycle every element
Two Laptop Bag

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture