[Home] [By Thread] [By Date] [Recent Entries]

  • From: "Michael Kay" <mike@s...>
  • To: "'Minas Casiou'" <casi1min@p...>,<xml-dev@l...>
  • Date: Tue, 5 Dec 2006 23:29:47 -0000

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: 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.





[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member