Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Require help with XSL

Status
Not open for further replies.

nizarhandal

Programmer
Aug 3, 2006
6
PS
Dear Programmers,

I am new to XML/XSL and I need a XSL file that will show all the texts between the <p> tags in this XML file:

<?xml version="1.0"?>
<NewsML>
<Catalog Href=" <NewsEnvelope>
<DateAndTime>20060603T061859Z</DateAndTime>
</NewsEnvelope>
<NewsItem>
<Identification>
<NewsIdentifier>
<ProviderId>afp.com</ProviderId>
<DateId>20060603</DateId>
<NewsItemId>060603061851.sff41n7v</NewsItemId>
<RevisionId PreviousRevision="0" Update="N">1</RevisionId>
<PublicIdentifier>urn:newsml:afp.com:20060603:060603061851.sff41n7v:1</PublicIdentifier>
</NewsIdentifier>
<NameLabel>???/???????</NameLabel>
</Identification>
<NewsManagement>
<NewsItemType FormalName="News"/>
<FirstCreated>20060603T061851Z</FirstCreated>
<ThisRevisionCreated>20060603T061851Z</ThisRevisionCreated>
<Status FormalName="Usable"/>
</NewsManagement>
<NewsComponent>
<NewsLines>
<HeadLine>??????? 2006: ??? ??????? ??? ???????? 3-??? ???? ??? ???????? ???????</HeadLine>
<CopyrightLine>????? ????? ??? © 2006</CopyrightLine>
<SlugLine>???/??????? ????</SlugLine>
</NewsLines>
<AdministrativeMetadata>
<Provider>
<Party FormalName="AFP"/>
</Provider>
</AdministrativeMetadata>
<DescriptiveMetadata>
<Language FormalName="ar"/>
<OfInterestTo FormalName="mmd--arabic--journal--sport"/>
</DescriptiveMetadata>
<NewsComponent>
<ContentItem>
<MediaType FormalName="Text"/>
<Format FormalName="bcNITF2.5"/>
<DataContent>
<media media-type="image" style="rightSide">
<media-reference mime-type="" data-location="#photo0"/>
</media>
<p>???????????? (???????) (? ? ?)- ??? ????? ???????? ???? ????? ??? ????? ????????? 3-??? ?????? ?? ???????????? (???) ?? ???? ????????? ????? ???????? ??????? 2006 ?? 9 ??????/????? ??? 9 ????/????? ?? ???????.</p>
<p>???? ?????? ????? (20) ???????? ??????????? (37) ???? ???????? (69) ???????.</p>
<p>????? ??????? ?? ????????? ??? ????????? ?????? ??? ???? ????????? ??????? ??????????.</p>
<p>??? ???? ????? ??? ????? ?? ???? ????? ??? ?????? ????? ???????? ??????? ???? ?????????? ???? ????? ???? ???????? ????????? ????? ??? ??????? ?????? ?? ??? ?????? ??? ?????? ?? ??? ?????? ??? ??? ??? ?????? ?? ????? ????? ?? ???????????? "??? ?? ???? ???????? ??????? ??? ??????? ??? ????? ????? ????? ???? ?? ???? ????? ??????? ????? ?????? ?????? ????? ????? ?? ?? ??????".</p>
<p>????? "????? ?????? ?????? ??? ??? ??? ????? ?? ??????? (2-2) ????? ???? ?????? ?? ????????? ???? ????? ?? ???? ??? ??????. ??? ?? ???? ?????? ?????? ?? ????????? ?? ????? ????? ???? ????????? ?????????? ???????".</p>
<p>???? "???? ?????? ???? ????? ???? ????? ???? ??? ???????? ??? ??????? ?? ????? ???? ?? ?????? ???? ???? ???????? ????????? ????????".</p>
<p>???? ???????? ???? ????? ?? ??/????? 2004 ??? ????? ??????? ?? ???? ?????? ?????? ?? ????? ????? ???? ????? ????????? ??? 2004 ?? ????????.</p>
<p>????? ???????? ?? ??? ?????? ???????? ????? ????? ?? ?????? ???????? ?????????? ?? ????????? ?? 9 ?????? ??? ?????? ???????? ?? ?????? ??????? ??? ???????? ??? ???? ????? ??? ????? ???? ??? ??? ???? ???????? ???? ???? ??? ????? ??? ??????? ?????????.</p>
<p>???? ??????????? ????? ??????? ?? ??????? ??????? ??? ???? ????? ??????? ???? ?????? ?? ??? ????? ??????? ???? ???? ??? ????? ?????? ??? ?????? ???????? ?? ????????? 9 ?12 ?????? ????? ?????? ????????? ?????.</p>
<p>???? ??????????? ???? ???? ??? ?????? ?????? ????? ???? ???? ?????? ????????? ??? ????? ????? ????? ???? ?????? ?????? ????????? ?? 65 ?????? (21).</p>
<p>???? ????? ????? ???? ???? ??????? ??????? ????? ?????? ??????? (28) ???? ???? ?????? ????? ??? ????? ????????? ????? ???? ????? ???? ????? ?????? ???????? (34) ??? ?? ????? ??????????? ???? ??????? ???????? ??????? ???? ??? ?? ???? ??? ?????? ???? ??? 25 ???? (37).</p>
<p>??? ??????? 41 ???? ????? ???? ?? ???? ??? ?? ???? ??? ?????? ?? ????? ???????? ??? ?????? ?????? ??????? ?????? ?? ?????? ???? ???????.</p>
<p>????? ???? ??????? ???????? ???? ??? ??? 45 ??? ????? ????? ?? ???? ????? ??? ????? ????? ?? ????????? ?????? ???? (62) ?? ???? ????? ?????? ??? ????? (65) ??? ?? ???? ??? ???????? ??????? ???? ??? ?????? ??????? ???????? ????????? ??????? ????????.</p>
<p>?????? ???????? ?????? ????? ????? ?? ??? ?????? ????????? ???? ???? ??????? ???? ???? (69) ????? ??? ?????? ???? ????? ??????? ??? ?????? ?????????.</p>
</DataContent>
</ContentItem>
</NewsComponent>
<NewsComponent Duid="photo0">
<NewsLines>
<HeadLine>????? ??????? ???????? ??????? ?????? ??? ???????? </HeadLine>
</NewsLines>
<AdministrativeMetadata>
<Provider>
<Party FormalName="?? ?/?? ?? ?? "/>
</Provider>
<Creator>
<Party FormalName="?????? ???? "/>
</Creator>
</AdministrativeMetadata>
<NewsComponent>
<Role FormalName="Caption"/>
<ContentItem>
<MediaType FormalName="Text"/>
<Format FormalName="bcNITF2.5"/>
<DataContent>
<p>??? ????? ???????? ???? ????? ??? ????? ????????? 3-??? ?????? ?? ???????????? (???) ?? ???? ????????? ????? ???????? ??????? 2006 ?? 9 ??????/????? ??? 9 ????/????? ?? ???????.</p>
</DataContent>
</ContentItem>
</NewsComponent>
<NewsComponent>
<Role FormalName="Thumbnail"/>
<ContentItem Href="SGE.CXV92.030606061846.photo00.thumbnail.default-65x100.jpg">
<MediaType FormalName="Photo"/>
<Characteristics>
<Property FormalName="Width" Value="65"/>
<Property FormalName="Height" Value="100"/>
</Characteristics>
</ContentItem>
</NewsComponent>
<NewsComponent>
<Role FormalName="Quicklook"/>
<ContentItem Href="SGE.CXV92.030606061846.photo00.quicklook.default-161x245.jpg">
<MediaType FormalName="Photo"/>
<Characteristics>
<Property FormalName="Width" Value="161"/>
<Property FormalName="Height" Value="245"/>
</Characteristics>
</ContentItem>
</NewsComponent>
<NewsComponent>
<Role FormalName="Preview"/>
<ContentItem Href="SGE.CXV92.030606061846.photo00.photo.default-337x512.jpg">
<MediaType FormalName="Photo"/>
<Characteristics>
<Property FormalName="Width" Value="337"/>
<Property FormalName="Height" Value="512"/>
</Characteristics>
</ContentItem>
</NewsComponent>
</NewsComponent>
</NewsComponent>
</NewsItem>
</NewsML>

Thanks
 
You have not said what method to output. Let's say to a text. This is how you do it.
[tt]
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="<xsl:eek:utput method="text" encoding="utf-8" />
<xsl:template match="/">
<xsl:apply-templates select="//p" />
</xsl:template>
<xsl:template match="//p">
<!-- some formatting you don't have to follow -->
<xsl:text>[</xsl:text><xsl:value-of select="position()" /><xsl:text>]&#x0d;&#x0a;</xsl:text>
<xsl:value-of select="normalize-space(.)" />
<xsl:text>&#x0d;&#x0a;</xsl:text>
</xsl:template>
</xsl:stylesheet>
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top