Hi,

i need help with xsl document. I want to create xsl document, where header of invoice will be join items of invoice. In my document is separated and i donĀ“t know how to do it. For example, i want that number of proof has items and then continue with next number. Example is in attachment.

thanks

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions"
                xmlns:dat="http://www.stormware.cz/schema/data.xsd" xmlns:pri="http://www.stormware.cz/schema/prijemka.xsd" xmlns:typ="http://www.stormware.cz/schema/type.xsd" xmlns:rsp="http://www.stormware.cz/schema/response.xsd"
                xmlns:lst="http://www.stormware.cz/schema/list.xsd">
	<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
	<xsl:template match="text()|@*">
	</xsl:template>
	<xsl:template match="/">
		<root>
			<pri:prijemkaHeader>
				<xsl:apply-templates select="//pri:prijemkaHeader"/>
			</pri:prijemkaHeader>

			<pri:prijemkaDetail>
				<xsl:apply-templates select="//pri:prijemkaDetail"/>
			</pri:prijemkaDetail>
		</root>
	</xsl:template>
	
	<xsl:template match="//pri:prijemkaHeader">
		<xsl:apply-templates/>
		</xsl:template>
	<xsl:template match="pri:number">
	<xsl:element name="pri:number">
		<xsl:value-of select="./typ:numberRequested"/>
	</xsl:element>
		<xsl:element name="pri:date">
			<xsl:value-of select="./pri:date"/>
		</xsl:element>
		<xsl:element name="pri:text">
		<xsl:value-of select="./pri:text"/>
		</xsl:element>
		<xsl:element name="pri:partnerIdentity">
		<xsl:element name="typ:address">
		<xsl:element name="typ:company">
		<xsl:value-of select="./pri:partnerIdentity/typ:address/typ:company"/>
		</xsl:element>
		<xsl:element name="typ:division">
		<xsl:value-of select="./pri:partnerIdentity/typ:address/typ:division"/>
		</xsl:element>
		<xsl:element name="typ:name">
		<xsl:value-of select="./pri:partnerIdentity/typ:address/typ:name"/>
		</xsl:element>
		<xsl:element name="typ:city">
		<xsl:value-of select="./pri:partnerIdentity/typ:address/typ:city"/>
		</xsl:element>
		<xsl:element name="typ:street">
		<xsl:value-of select="./pri:partnerIdentity/typ:address/typ:street"/>
		</xsl:element>
		<xsl:element name="typ:zip">
		<xsl:value-of select="./pri:partnerIdentity/typ:address/typ:zip"/>
		</xsl:element>
		<xsl:element name="typ:ico">
		<xsl:value-of select="../pri:partnerIdentity/typ:address/typ:ico"/>
		</xsl:element>
		<xsl:element name="typ:dic">
		<xsl:value-of select="./pri:partnerIdentity/typ:address/typ:dic"/>
		</xsl:element>
		</xsl:element>
		<xsl:element name="typ:shipToAddress">
		<xsl:element name="typ:name">
		<xsl:value-of select="./pri:partnerIdentity/typ:shipToAddress/typ:name"/>
		</xsl:element>
		<xsl:element name="typ:city">
		<xsl:value-of select="./pri:partnerIdentity/typ:shipToAddress/typ:city"/>
		</xsl:element>
		<xsl:element name="typ:street">
		<xsl:value-of select="./pri:partnerIdentity/typ:shipToAddress/typ:street"/>
		</xsl:element>
		</xsl:element>
		</xsl:element>
		</xsl:template>
		
		<xsl:template match="//pri:prijemkaDetail">
		<xsl:apply-templates/>
	</xsl:template>
		<xsl:template match="pri:prijemkaItem">
		 <xsl:element name="pri:prijemkaItem">
			<xsl:element name="pri:text">
			<xsl:value-of select="./pri:text"/>	
			</xsl:element>
			<xsl:element name="pri:quantity">
			<xsl:value-of select="./pri:quantity"/>	
			</xsl:element>
			<xsl:element name="pri:unit">
			<xsl:value-of select="./pri:unit"/>	
			</xsl:element>
			<xsl:element name="pri:coefficient">
			<xsl:value-of select="./pri:coefficient"/>	
			</xsl:element>
			<xsl:element name="pri:rateVAT">
			<xsl:value-of select="./pri:rateVAT"/>	
			</xsl:element>
			<xsl:element name="pri:stockItem">
			<xsl:element name="typ:stockItem">
			<xsl:element name="typ:ids">
			<xsl:value-of select="./pri:stockItem/typ:stockItem/typ:ids"/>	
			</xsl:element>
			</xsl:element>			
			</xsl:element>
			</xsl:element>
			</xsl:template>
</xsl:stylesheet>

i not and not sure what you are after. It is hard to understand.

But I notice that your code is very verbose. for example

<xsl:element name="pri:partnerIdentity"></xsl:element> can be written as

<pri:partnerIdentity></pri:partnerIdentity>

To be more clear, please post your input XML, XSLT code and the expected output XML.

Hi,

in attachment send inputXML, xsl and expected XML.

thanx a lot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.