Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xml-dev] XSLT that does uppercase translation of all attributes and elements...

From: "Michael Kay" <mike@--------.--->
To: "'Minas Casiou'" <casi1min@------.---.---.-->,<xml-dev@-----.---.--->
Date: 12/5/2006 11:30:00 PM
After xsl:element, use <xsl:copy-of 
select="namespace::*"> to copy all the namespace declarations from the source 
document to the result.
 
Michael Kay
http://www.saxonica.com/


  
  
  From: Minas Casiou 
  [mailto:casi1min@p...] 
Sent: 05 December 2006 
  21:35
To: xml-dev@l...
Cc: 
  xml-dev@l...
Subject: [xml-dev] XSLT that does uppercase 
  translation of all attributes and elements...


  
Hi all, 
I've got an XSLT that attempts to translate all attribute 
  and element values to UPPERCASE (using XSLT 1.0 at the moment). 
  
Unfortunately my current solution is leaving 
  out the namespace prefix declarations out ... 
Any ideas anyone? 


Sample Request 

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:esb="urn:au.gov.nsw.police.xml.esb.common.version_1_0_0" 
 xmlns:inc="urn:au.gov.nsw.police.xml.model.incident.incidentModel.version_1_0_0" 
xmlns:as4590="urn:au.gov.nsw.justiceSector.cim.as4590"> 
        <SOAP-ENV:Body> 
                <svc:WriteOffIncidentRq 
  xmlns:svc="urn:au.gov.nsw.police.xml.service.incident.incidentService.version_1_0_0"> 
    
                      
  <esb:Header> 
            
                      
  <esb:ReplyTo> 
                    
                      
  <esb:AddressURL>String</esb:AddressURL> 
                    
                      
  <esb:Type>WebService</esb:Type> 
  
                
                  </esb:ReplyTo> 
                    
              <esb:Sender> 
            
                        
        <esb:MessageID>String</esb:MessageID> 
        
                        
            <esb:CorrelationID>CorrID123</esb:CorrelationID> 
        
                        
    </esb:Sender> 
                    
              <esb:Credentials> 
        
                        
            <esb:UserID>406594</esb:UserID> 
        
                        
            <esb:Role>String</esb:Role> 
            
                      
  </esb:Credentials> 
                    
      </esb:Header> 

                    
      <inc:Incident> 
                    
              <inc:RequestingIPAddress>20.15.26.152</inc:RequestingIPAddress> 
        </inc:Incident> 
                </svc:WriteOffIncidentRq> 
  
        </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

XSLT to convert to 
  uppercase 
<?xml version="1.0" 
  encoding="UTF-8"?> 
<xsl:stylesheet 
  version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:import href="identity.xslt"/> 
<xsl:output 
  method="xml" version="1.0" encoding="UTF-8" indent="yes"/> 

        <xsl:template match="*" > 
                <xsl:element name="{local-name()}"       
   namespace="{namespace-uri()}"> 
                    
      <xsl:for-each select="../@*"> 
            
                      
  <xsl:attribute name="{name()}" > 
            
                        
        <xsl:value-of 
  select="translate(. , 
  $vLowercaseChars_CONST , $vUppercaseChars_CONST)"/> 
          
                        </xsl:attribute> 
                        </xsl:for-each> 
                        <xsl:apply-templates select="node()|@*"/> 
                </xsl:element> 
        </xsl:template> 

        <xsl:template match="text()" 
  > 
    
              <xsl:value-of select="translate(. , $vLowercaseChars_CONST , 
  $vUppercaseChars_CONST)"/> 
        </xsl:template> 

        
  <xsl:variable name="vLowercaseChars_CONST" select="'abcdefghijklmnopqrstuvwxyz'"/> 
        
  <xsl:variable name="vUppercaseChars_CONST" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/> 

</xsl:stylesheet> 

Sample 
  Response 
<?xml version="1.0" 
  encoding="UTF-8"?> 
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> 
        <Body> 
        
          <WriteOffIncidentRq 
  xmlns="urn:au.gov.nsw.police.xml.service.incident.incidentService.version_1_0_0"> 
        
                  <Header xmlns="urn:au.gov.nsw.police.xml.esb.common.version_1_0_0"> 
        
                        
    <ReplyTo> 
                    
                      
  <AddressURL>STRING</AddressURL> 
                    
                      
  <Type>WEBSERVICE</Type> 
                    
              </ReplyTo> 
            
                      
  <Sender> 
                    
                      
  <MessageID>STRING</MessageID> 
                    
                      
  <CorrelationID>CORRID123</CorrelationID> 
                    
              </Sender> 
            
                      
  <Credentials> 
                    
                      
  <UserID>406594</UserID> 
                    
                      
  <Role>STRING</Role> 
  
                        
          </Credentials> 
  
                
          </Header> 
  
                
          <Incident xmlns="urn:au.gov.nsw.police.xml.model.incident.incidentModel.version_1_0_0"> 
        
                        
    <RequestingIPAddress>20.15.26.152</RequestingIPAddress> 
            
              </Incident> 
            
      </WriteOffIncidentRq> 
        </Body> 
</Envelope> 
  
Note that the: 

xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:esb="urn:au.gov.nsw.police.xml.esb.common.version_1_0_0" 
 xmlns:inc="urn:au.gov.nsw.police.xml.model.incident.incidentModel.version_1_0_0" 
xmlns:as4590="urn:au.gov.nsw.justiceSector.cim.as4590"> 

namespace prefix 
  declarations are all missing... 

Any 
  ideas anyone? 

Thanks 


Cheers 
  
Minas Casiou 
  |  ESB Technical 
  Architect I&I | MRP -  Mainframe Replacement 
  Program    |  BTS  
  |  New  South  Wales  Police 
  
Phone: 02 9689 7610 |  Eaglenet: 79610  |  Mobile: 0431 103 
  925  |  email: casi1min@p... 
  
    
    
      This message and any attachment 
        is confidential and may
be privileged or otherwise protected from 
        disclosure. If you
have received it by mistake, please let us know by 
        reply
and then delete it from your system; you should not copy 
        
the message or disclose its contents to 
        anyone.


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent