Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 9th, 2013, 03:19 AM
Authorized User
Points: 151, Level: 3
Points: 151, Level: 3 Points: 151, Level: 3 Points: 151, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2013
Posts: 31
Thanks: 3
Thanked 0 Times in 0 Posts
Default XSLT from two XMLs

Hi,
i'm new to xslt advanced program. i actually have a doubt in making an xslt from 2 different xml files.

Below are the 2 xml files i have.

AHK-authors.xml

HTML Code:
<?xml version="1.0" encoding="UTF-8"?>
<chapters>
	<chapter no="1">
		<head-4>By J. R. Weeramantry</head-4>
	</chapter>
	<chapter no="2">
		<head-4>By Ernest Yang<footnote id="AHK-02.1.fn0" prefix="*">
				<footnote-para>I would like to acknowledge and express my gratitude for the assistance provided by my colleagues, Mr. Kevin Hong and Ms. Sharon Leung, in the preparation of this Chapter. All errors and omissions are my own. </footnote-para>
			</footnote>
		</head-4>
	</chapter>
	<chapter no="3">
		<head-4>By David Bateson and Edmund Wan</head-4>
	</chapter>
	<chapter no="4">
		<head-4>By Timothy Hill and Mark Lin</head-4>
	</chapter>
	<chapter no="5">
		<head-4>By Christopher To<footnote id="AHK-05.1.fn0" prefix="*">
				<footnote-para>I would like to acknowledge Alan Tang Siu Lun for his assistance in compiling parts of the Chapter.</footnote-para>
			</footnote>
		</head-4>
	</chapter>
	<chapter no="6">
		<head-4>By Chiann Bao</head-4>
	</chapter>
	<chapter no="7">
		<head-4>By Justin D’Agostino and Ula Cartwright-Finch</head-4>
	</chapter>
	<chapter no="8">
		<head-4>By Kim M. Rooney</head-4>
	</chapter>
	<chapter no="9">
		<head-4>By Neil Kaplan QC, JP, CBE, SBS and Andrew Aglionby</head-4>
		<head-5>[Revised and Updated by William Stone QC, SBS]<footnote id="AHK-09.1.fn0" prefix="*">
				<footnote-para>With thanks to summer students Chadwick Wong and Cheryl Leung.</footnote-para>
			</footnote>
		</head-5>
	</chapter>
	<chapter no="10">
		<head-4>By Frances van Eupen</head-4>
	</chapter>
	<chapter no="11">
		<head-4>By Peter Yuen and John Choong</head-4>
	</chapter>
	<chapter no="12">
		<head-4>By David Bateson and Edmund Wan</head-4>
	</chapter>
	<chapter no="13">
		<head-4>By Teresa Cheng SC<footnote id="AHK-13.1.fn0" prefix="*">
				<footnote-para>Special thanks to Andrew Aglionby, Joy Medd and Johnson Tan, co-authors to the first edition of this chapter, as portions of their work has been retained herein.</footnote-para>
			</footnote>
		</head-4>
	</chapter>
	<chapter no="14">
		<head-4>By Paul Starr<footnote id="AHK-14.1.fn0" prefix="*">
				<footnote-para>Heartfelt thanks to Jennifer Lee-Shoy, Stefania Lucchetti, Samuel Tang and Rita Wong.</footnote-para>
			</footnote>
		</head-4>
	</chapter>
	<chapter no="15">
		<head-4>By Timothy Hill and Mark Lin</head-4>
	</chapter>
	<chapter no="16">
		<head-4>By Denis Brock and Shirley Wu</head-4>
	</chapter>
	<chapter no="17">
		<head-4>By Peter Chow</head-4>
	</chapter>
	<chapter no="18">
		<head-4>By Paul Starr<footnote id="AHK-18.1.fn0" prefix="*">
				<footnote-para>Heartfelt thanks to Jennifer Lee-Shoy, Samuel Tang and Rita Wong for their assistance with this chapter.</footnote-para>
			</footnote>
		</head-4>
	</chapter>
	<chapter no="19">
		<head-4>By Kathryn Sanger, Joseph Chu and Bing Yu</head-4>
	</chapter>
	<chapter no="20">
		<head-4>By Loke-Khoon Tan</head-4>
	</chapter>
	<chapter no="21">
		<head-4>By Philip Yang and Rosita Lau</head-4>
	</chapter>
	<chapter no="22">
		<head-4>By Marianne Chao</head-4>
	</chapter>
	<chapter no="23">
		<head-4>By Dr Nils Eliasson</head-4>
	</chapter>
	<chapter no="24">
		<head-4>Banking, International Investor-State, Insurance, Property and Employment Disputes</head-4>
		<head-5>By Frances van Eupen, Vincent Li, Gary Soo and Alexander Stock</head-5>
	</chapter>
</chapters>

ARBHK-Chapter01.xml

HTML Code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="xsl" ref="Untitled28.xslt"?>
<chapter num="A">
	<title>
		<content-style font-style="bold">PART 1 GENERAL PRINCIPLES</content-style>
	</title>
	<section level="sect1">
		<title>
			<content-style font-style="bold">Chapter 1: THE NEW ARBITRATION ORDINANCE</content-style>
		</title>
	</section>
</chapter>

and the xslt i tried is as below
Untitled28.xslt

HTML Code:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
	<xsl:output method="html" encoding="UTF-8" indent="yes"/>
	<xsl:template match="/">
		
		<html>
			<head>
				<xsl:text disable-output-escaping="yes"><![CDATA[</meta>]]></xsl:text>
				<title>
					<xsl:value-of select="substring-after(chapter/section/title,':')"/>
				</title>
				<link rel="stylesheet" href="er:#css" type="text/css"/><xsl:text disable-output-escaping="yes"><![CDATA[</link>]]></xsl:text>
			</head>
			<body>
				<xsl:call-template name="new"/>
			</body>
		</html>
	</xsl:template>
	
<xsl:template match="chapters/chapter" name="new">
<div class="new">
<xsl:apply-templates select="document('AHK-authors.xml')/head-4">
</xsl:apply-templates>
</div>
</xsl:template>	
</xsl:stylesheet>
the o/p i'm getting is as below

HTML Code:
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	</meta>
		<title> THE NEW ARBITRATION ORDINANCE</title>
		<link rel="stylesheet" href="er:#css" type="text/css"/>
	</head>
	<body>
		<div class="new"/>
	</body>
</html>
but i want <div class="new"/> to list all the authors information.

please let me know how do i do it.

Thanks
Reply With Quote
  #2 (permalink)  
Old April 10th, 2013, 01:14 PM
Friend of Wrox
Points: 1,676, Level: 16
Points: 1,676, Level: 16 Points: 1,676, Level: 16 Points: 1,676, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2006
Location: , , .
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Code:
<xsl:apply-templates select="document('AHK-authors.xml')/head-4">

Will select
head-4 from the root, which there is none. You need

Code:
<xsl:apply-templates select="document('AHK-authors.xml')/chapters/chapter/head-4">
Reply With Quote
The Following User Says Thank You to bonekrusher For This Useful Post:
sunnykeerthi (April 12th, 2013)
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change XMLs chameleon XSLT 2 November 12th, 2009 11:53 AM
Grouping xmls sac XSLT 4 July 29th, 2008 04:16 AM
Multiple xmls and xsls pasupathy.b XSLT 6 June 4th, 2007 01:07 PM
XML element referencing to other xmls alexhinz XSLT 0 February 8th, 2007 09:32 AM
dynamic xslt -> xslt creation namespace problem jkmyoung XSLT 2 July 15th, 2006 12:42 AM



All times are GMT -4. The time now is 10:55 PM.


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