XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 28th, 2011, 10:50 PM
aliabbas_aa aliabbas_aa is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2011
Posts: 3 aliabbas_aa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 30 sec
Reputation Power: 0
XSLT transformation not giving the desired results

i want to transform xml file yusuf.xml collapsing all elements like suraid,verseid etc except <yusuf> as attributes:
Code:
<ahmed>
		<suraid>1</suraid>
		<verseid>3</verseid>
		<groupcode>1.2-4</groupcode>
		<yusuf>Most Gracious, Most Merciful;</yusuf>
	</ahmed>
	<ahmed>
		<suraid>1</suraid>
		<verseid>4</verseid>
		<groupcode>1.2-4</groupcode>
		<yusuf>Master of the Day of Judgment.</yusuf>
	</ahmed>


above code should look like
Code:
<quran suraid="1" verseid="3" groupcode="1.2-4" author="yusuf">
Most Gracious, Most Merciful;
</quran>
<quran suraid="1" verseid="4" groupcode="1.2-4" author="yusuf">
Master of the Day of Judgment;
</quran>



see to it that i want the verse contents in the <quran> tag

below is my schema xsd for above ,its not giving the desired result :
Code:

<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2011 rel. 2 (x64) (http://www.altova.com) by aliabbas (puu) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<xs:element name="quran">
		<xs:complexType>
			<xs:simpleContent>
				<xs:extension base="xs:string">
					<xs:attribute name="verseid" type="xs:unsignedShort"/>
					<xs:attribute name="suraid" type="xs:unsignedByte" use="required"/>
					<xs:attribute name="groupcode" type="xs:string"/>
					<xs:attribute name="author" type="xs:string" use="required"/>
				</xs:extension>
			</xs:simpleContent>
		</xs:complexType>
	</xs:element>
</xs:schema>

following is the transformation xsl file
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs">
	<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
	<xsl:template match="/">
		<xsl:variable name="var1_dataroot" select="dataroot"/>
		<quran>
			<xsl:attribute name="xsi:noNamespaceSchemaLocation" namespace="http://www.w3.org/2001/XMLSchema-instance">C:/Users/ALI/Documents/transform.xsd</xsl:attribute>
			<xsl:for-each select="$var1_dataroot/ahmed/verseid">
				<xsl:attribute name="verseid">
					<xsl:value-of select="string(floor(number(string(.))))"/>
				</xsl:attribute>
			</xsl:for-each>
			<xsl:for-each select="$var1_dataroot/ahmed/suraid">
				<xsl:attribute name="suraid">
					<xsl:value-of select="string(floor(number(string(.))))"/>
				</xsl:attribute>
			</xsl:for-each>
			<xsl:for-each select="$var1_dataroot/ahmed/groupcode">
				<xsl:attribute name="groupcode">
					<xsl:value-of select="string(.)"/>
				</xsl:attribute>
			</xsl:for-each>
		</quran>
	</xsl:template>
</xsl:stylesheet>


i used mapforce but i cant get the contents of each verse in individual <quran> tag

and i am getting only one <quran > instance as output
please help me

Reply With Quote
  #2  
Old March 1st, 2011, 01:33 AM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,676 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 1 h 40 m 59 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
You need to do a (just one) for-each on <ahmed>.
Code:
for-each ahmed
	attribute suraid: value-of suraid
	attribute verseid: value-of verseid
	attribute groupcode: value-of groupcode
	value-of yusuf

Or you can use a template.

Reply With Quote
  #3  
Old March 1st, 2011, 05:02 AM
aliabbas_aa aliabbas_aa is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2011
Posts: 3 aliabbas_aa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 30 sec
Reputation Power: 0
i urgently need a solution

thanx
where to execute the above code
and should i type exactly like this ?
i am new to xsl etc and i donno xpath much

i am using xml spy software but i donno much abt xslt stylesheets ,xquery
please help me i need to finish this task fast for further research work

Reply With Quote
  #4  
Old March 2nd, 2011, 02:57 AM
aliabbas_aa aliabbas_aa is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2011
Posts: 3 aliabbas_aa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 30 sec
Reputation Power: 0
i got it !! see beloew
but i want to repeat the procedure for multiple files how to automate this proc?'


<?xml version="1.0" encoding="UTF-8"?>
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:template match="dataroot">
		<collection>
			<xsl:for-each select="ahmed">
				<quran>
					<xsl:attribute name="suraid">
						<xsl:value-of select="suraid"/>
					</xsl:attribute>
					<xsl:attribute name="verseid">
						<xsl:value-of select="verseid"/>
					</xsl:attribute>
					<xsl:attribute name="groupcode">
						<xsl:value-of select="groupcode"/>
					</xsl:attribute>
					<xsl:attribute name="author">
						<xsl:text>shakir</xsl:text>
					</xsl:attribute>
					<xsl:value-of select="shakir"/>
				</quran>
			</xsl:for-each>
		</collection>
	</xsl:template>
</xsl:stylesheet>

Reply With Quote
  #5  
Old March 4th, 2011, 04:09 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,676 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 1 h 40 m 59 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
Then your best bet is to write some kind of not-XSLT script to get the files and run them each through an XSLT processor.

For example, with PHP you can write something that uses glob and XSLTProcessor.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XSLT transformation not giving the desired results

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap