Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 10th, 2009, 04:08 PM
Authorized User
 
Join Date: Sep 2008
Posts: 56
Thanks: 0
Thanked 1 Time in 1 Post
Default how to read xml files doing select="document()" ?

Here is my sample xml

<?xml version="1.0"?>
<abc:testNews xmlns:rcdc="http://abc.com" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:chiba="http://chiba.sourceforge.net/xforms">
<abc:pageDetails>
<abc:year>2007</abc:year>
<abc:pressRelease>
<abc:newsXMLPath>/press1.xml</abc:newsXMLPath>
</abc:pressRelease>
<abc:pressRelease>
<abc:newsXMLPath>/press2.xml</abc:newsXMLPath>
</abc:pressRelease>
</abc:pageDetails>
</abc:testNews>

press1.xml and press2.xml have same structure for example.
<news>
<title>News One </title>
<intro> This is introduction</intro>
</news>

Here is my XSL

<xsl:stylesheet version="2.0" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:abc="http://abc.com" xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:exsl="http://exslt.org/common" exclude-result-prefixes="xhtml">
<xsl:template match="/">
<xsl:for-each select="//abc:pressRelease">
<xsl:value-of select="abc:newsXMLPath"/>
</xsl:for-each>
<xsl:variable name="xmlpath" select="document('abc:newsXMLPath')"/>
</xsl:template>
</xsl:stylesheet>

This is an incomplete XSL. basically I am trying to print the Title of each news. News1 and news2.xml. Am I doing this wrong? What do I need to do in order to first get the xml location and than loop through to get the value of each title for news1 and news2.?
 
Old February 10th, 2009, 04:51 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You want something like

<xsl:for-each select="//abc:pressRelease">
<xsl:value-of select="document(abc:newsXMLPath)/news/title"/>
</xsl:for-each>
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old February 10th, 2009, 05:08 PM
Authorized User
 
Join Date: Sep 2008
Posts: 56
Thanks: 0
Thanked 1 Time in 1 Post
Default

Awesome that worked. U are great mhkay.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Message received by "FILE" adapter is suspended skindika Biztalk 0 February 2nd, 2009 07:06 PM
Earthquake Example problem "non-application token" Langley BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 2 January 28th, 2009 02:29 PM
WebPart not supporting/enabled displaymode other than "Browse" amitjoshipune ASP.NET 2.0 Professional 1 January 9th, 2009 02:34 PM
google Response.Write(Request.QueryString("q")) senol01 ASP.NET 2.0 Basics 1 January 2nd, 2009 12:01 PM
pgs. 506-512 "r" ? Rachel BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 January 2nd, 2009 05:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.