Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| 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 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
  #1 (permalink)  
Old July 8th, 2010, 06:32 AM
Authorized User
 
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
Default How do we include the namespace and xsd as attributes to the tag

Hi,

I am using XSL1.0 version
In my xsl file using name space like
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
In my output should be like below as
Code:
<dokument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="universal.xsd">
<hlavicka>		
    <identifikacneCislo>			
      <kodStatu/>			
      <dic><![CDATA[2020372640]]></dic>		
    </identifikacneCislo>		
    <danovyUrad/>		
    <druhSV>			
      <riadny><![CDATA[1]]></riadny>			
      <opravny><![CDATA[0]]></opravny>			
      <dodatocny><![CDATA[0]]></dodatocny>		
    </druhSV>
</hlavicka>
</dokument>
How do we add name space and xsd as a attribute to the corresponding tag?
Pleae help me out.

Regards,
Jyotsna.
  #2 (permalink)  
Old July 8th, 2010, 06:39 AM
Friend of Wrox
Points: 6,676, Level: 34
Points: 6,676, Level: 34 Points: 6,676, Level: 34 Points: 6,676, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Put the namespace declaration on the xsl:stylesheet element e.g.
Code:
<xsl:stylesheet
  xmns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  ...
</xsl:stylesheet>
As for xsi:noNamespace, that is simply an attribute so add that as a literal attribute on the literal result element, when you create the "dokument" element.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
The Following User Says Thank You to Martin Honnen For This Useful Post:
anarleti (July 8th, 2010)
  #3 (permalink)  
Old July 8th, 2010, 07:12 AM
Authorized User
 
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Martin Honnen View Post
Put the namespace declaration on the xsl:stylesheet element e.g.
Code:
<xsl:stylesheet
  xmns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  ...
</xsl:stylesheet>
As for xsi:noNamespace, that is simply an attribute so add that as a literal attribute on the literal result element, when you create the "dokument" element.
Hi Martin,

Thanks for your reply.

Regards,
Jyotsna.
  #4 (permalink)  
Old July 8th, 2010, 07:43 AM
Authorized User
 
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by anarleti View Post
Hi Martin,

Thanks for your reply.

Regards,
Jyotsna.
Hi

I am uploading bellow xsl file
Code:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output  method="xml" indent="yes" omit-xml-declaration="no"/>
<!-- Root template -->
<xsl:template match="/">
<dokument><xsl:attribute name="xsi:noNamespaceSchemaLocation">universal.xsd</xsl:attribute>
<hlavicka>		
<identifikacneCislo>			
<kodStatu/>			
<dic><xsl:value-of select="substring(/ZXXEUSL/LIST_G_REP_PARAMETER_INFO/G_REP_PARAMETER_INFO/CP_FIRST_PARTY_TAX_REG_NUM,2,30)"/></dic><xsl:text>&#xD;</xsl:text>		
</identifikacneCislo>
<druhSV>			
<riadny><xsl:value-of select="1"/></riadny><xsl:text>&#xD;</xsl:text>			
<opravny><xsl:value-of select="0"/></opravny><xsl:text>&#xD;</xsl:text>			
<dodatocny><xsl:value-of select="0"/></dodatocny><xsl:text>&#xD;</xsl:text>		
</druhSV>
<obdobie>			
<mesiac><xsl:value-of select="substring(/ZXXEUSL/LIST_G_REP_PARAMETER_INFO/G_REP_PARAMETER_INFO/P_CUSTOM_CHAR4,4,2)"/></mesiac><xsl:text>&#xD;</xsl:text>				
<rok><xsl:value-of select="/ZXXEUSL/LIST_G_REP_PARAMETER_INFO/G_REP_PARAMETER_INFO/P_CUSTOM_CHAR3"/></rok><xsl:text>&#xD;</xsl:text>		
</obdobie>
<obchodneMeno>			
<riadok><xsl:value-of select="/ZXXEUSL/LIST_G_REP_PARAMETER_INFO/G_REP_PARAMETER_INFO/CP_ESTABLISHMENT_NAME"/></riadok><xsl:text>&#xD;</xsl:text>	
</obchodneMeno>	
<adresa>			
<ulica><xsl:value-of select="/ZXXEUSL/LIST_G_REP_PARAMETER_INFO/G_REP_PARAMETER_INFO/CP_ADDRESS_LINE_1"/></ulica><xsl:text>&#xD;</xsl:text>			
<cislo><xsl:value-of select="/ZXXEUSL/LIST_G_REP_PARAMETER_INFO/G_REP_PARAMETER_INFO/CP_ADDRESS_LINE_2"/></cislo><xsl:text>&#xD;</xsl:text>			
<psc><xsl:value-of select="/ZXXEUSL/LIST_G_REP_PARAMETER_INFO/G_REP_PARAMETER_INFO/CP_POSTAL_CODE"/></psc><xsl:text>&#xD;</xsl:text>			
<obec><xsl:value-of select="/ZXXEUSL/LIST_G_REP_PARAMETER_INFO/G_REP_PARAMETER_INFO/CP_TOWN_OR_CITY"/></obec><xsl:text>&#xD;</xsl:text>			
<tel>				
<predcislie></predcislie>				
<cislo></cislo>			
</tel>			
<fax>				
<predcislie></predcislie>				
<cislo></cislo>			
</fax>		
</adresa>		
<celkovaHodnota><xsl:value-of select="sum(/ZXXEUSL/LIST_G_REP_TRX_DETAIL_INFO/G_REP_TRX_DETAIL_INFO/C_FUNCTIONAL_TOTAL)"/></celkovaHodnota><xsl:text>&#xD;</xsl:text>		
<pocet2Stran><xsl:apply-templates select="ZXXEUSL" mode="temp2"/></pocet2Stran><xsl:text>&#xD;</xsl:text>		
<konatel></konatel>
<konatelTel>			
<predcislie></predcislie>			
<cislo></cislo>		
</konatelTel>
<datumVyhlasenia>			
<den><xsl:value-of select="substring(/ZXXEUSL/LIST_G_REP_PARAMETER_INFO/G_REP_PARAMETER_INFO/P_CUSTOM_CHAR4,1,2)"/></den><xsl:text>&#xD;</xsl:text>			
<mesiac><xsl:value-of select="substring(/ZXXEUSL/LIST_G_REP_PARAMETER_INFO/G_REP_PARAMETER_INFO/P_CUSTOM_CHAR4,4,2)"/></mesiac><xsl:text>&#xD;</xsl:text>			
<rok><xsl:value-of select="/ZXXEUSL/LIST_G_REP_PARAMETER_INFO/G_REP_PARAMETER_INFO/P_CUSTOM_CHAR3"/></rok><xsl:text>&#xD;</xsl:text>		
</datumVyhlasenia>
</hlavicka>
<telo>	
<strana>
<xsl:apply-templates select="/ZXXEUSL" mode="temp1"/> 
</strana>
</telo>
</dokument>	
</xsl:template>
<xsl:template name="t1" match="ZXXEUSL" mode="temp1">
<xsl:variable name="y"><xsl:apply-templates select="/ZXXEUSL" mode="temp2"/></xsl:variable>
<xsl:for-each-group select="LIST_G_REP_TRX_DETAIL_INFO/G_REP_TRX_DETAIL_INFO" group-by="concat(C_VAT_TAX_REG_NUM,C_BILLING_TP_SITE_NAME,C_TAX_REPORTING_NAME)">
<xsl:variable name="gds"><xsl:value-of select="/ZXXEUSL/LIST_G_REP_PARAMETER_INFO/G_REP_PARAMETER_INFO/CP_ESL_EU_GOODS_NAME"/></xsl:variable>
<xsl:variable name="serv"><xsl:value-of select="/ZXXEUSL/LIST_G_REP_PARAMETER_INFO/G_REP_PARAMETER_INFO/CP_ESL_EU_SERVICES_NAME"/></xsl:variable>
<xsl:variable name="trng"><xsl:value-of select="/ZXXEUSL/LIST_G_REP_PARAMETER_INFO/G_REP_PARAMETER_INFO/CP_ESL_EU_ADDL_CODE1_NAME"/></xsl:variable>
<xsl:if test="(((position()+3) mod 4) + 1) =  1 ">
<oznacenie>				
<aktualna><xsl:value-of select="(position()+3) idiv 4"/></aktualna><xsl:text>&#xD;</xsl:text>
<celkovo><xsl:value-of select="$y"/></celkovo><xsl:text>&#xD;</xsl:text>  			
</oznacenie>
</xsl:if> 			
<zaznam>				
<kodStatu><xsl:value-of select="substring(C_VAT_TAX_REG_NUM,1,2)"/></kodStatu><xsl:text>&#xD;</xsl:text>				
<idCislo><xsl:value-of select="substring(C_VAT_TAX_REG_NUM,3,30)"/></idCislo><xsl:text>&#xD;</xsl:text>				
<hodnota><xsl:value-of select="sum(current-group()/C_FUNCTIONAL_TOTAL)"/></hodnota><xsl:text>&#xD;</xsl:text>				
<xsl:if test="C_TAX_REPORTING_NAME =$gds"> 
<kod></kod><xsl:text>&#xD;</xsl:text>
</xsl:if>
<xsl:if test="C_TAX_REPORTING_NAME =$trng"> 
<kod>1</kod><xsl:text>&#xD;</xsl:text>
</xsl:if>
<xsl:if test="C_TAX_REPORTING_NAME =$serv"> 
<kod>2</kod><xsl:text>&#xD;</xsl:text>
</xsl:if>	
</zaznam>
</xsl:for-each-group>
</xsl:template>
<xsl:template name="tpgs" match="ZXXEUSL" mode="temp2">
<xsl:variable name="x">	
<xsl:for-each-group select="LIST_G_REP_TRX_DETAIL_INFO/G_REP_TRX_DETAIL_INFO" group-by="concat(C_VAT_TAX_REG_NUM,C_BILLING_TP_SITE_NAME,C_TAX_REPORTING_NAME)">
<P><xsl:value-of select="1"/></P><xsl:text>&#xD;</xsl:text>
</xsl:for-each-group>
</xsl:variable>
<xsl:for-each select="$x"> 
<xsl:variable name="jCount" select="sum(P)"/> 
<xsl:value-of select="ceiling($jCount div 4)"/> 
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
It is working perfectly in j developer but
I am unable to upload into applications
while uploading into applications its giving error as "The uploaded file CLEF347SK.xsl is invalid. The file should be in XSL format."

Regards,
Jyotsna.
  #5 (permalink)  
Old July 8th, 2010, 07:54 AM
Friend of Wrox
Points: 6,676, Level: 34
Points: 6,676, Level: 34 Points: 6,676, Level: 34 Points: 6,676, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

I don't know what kind of application that is and what kind of validation it performs. As your stylesheet uses XSLT 2.0 constructs like for-each-group you could try to set version="2.0" but that is just a guess, maybe it is better to look for a forum dedicated to the application you are using to find out how it validates uploaded files and how to find out more detailed error messages on to what exactly is wrong with the file.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
  #6 (permalink)  
Old July 8th, 2010, 08:14 AM
Authorized User
 
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Martin Honnen View Post
I don't know what kind of application that is and what kind of validation it performs. As your stylesheet uses XSLT 2.0 constructs like for-each-group you could try to set version="2.0" but that is just a guess, maybe it is better to look for a forum dedicated to the application you are using to find out how it validates uploaded files and how to find out more detailed error messages on to what exactly is wrong with the file.
Hi,

Thanks for your reply. we are uploading into Oracle Application R12 version.

Regards,
Jyotsna


Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove Namespace from tag using tag nisargmca XSLT 9 March 19th, 2010 06:40 AM
Declaring attributes for namespace declarations in DTDs. GrantRobertson BOOK: Beginning XML, 4th Ed ISBN: 978-0-470-11487-2 0 November 2nd, 2009 01:20 AM
namespace issue. xml and xsd jamesdurham XML 5 April 7th, 2009 07:13 PM
Include Namespace in .aspx.vb?? mikedeepak Visual Studio 2005 6 June 1st, 2007 04:31 AM
CH 9: A simple tag w/ attributes seeDerekNow JSP Basics 1 September 28th, 2003 11:20 PM





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