I am trying to Digitally Sign a node businessEntity. I am using Xpath in my tranform to refer to this node.
My Xpath expression is :
ancestor-or-self::ns1:businessEntity[
#businessKey = 'uddi:testSignedProviderlastime'
] and not(ancestor-or-self::ns1:businessService)
and not(ancestor-or-self::ds:Signature)
I want to remove the dependency for the namespace prefix ns1. Is there a way I can do that? Or is there a way I can specify the namespace URI in my expression.
I have already tried replacing the namespace prefix ns1 with a , but got an error for using "" prefix.
Any help in modifying this expression is appreciated.
Thanks,
Sonia
Following is the xml, I am applying this transform too:
<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<ns1:save_business xmlns:ns1="urn:uddi-org:api_v3">
<ns1:authInfo>something
</ns1:authInfo>
<ns1:businessEntity businessKey="uddi:testSignedProviderlastime" xmlns:ns1="urn:uddi-org:api_v3">
<ns1:name>testSignedProviderlastime</ns1:name>
<ns1:description>Not Provided</ns1:description>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"/>
<ds:Reference URI="" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:Transforms xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"/>
<ds:Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:XPath xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ns1="urn:uddi-org:api_v3">ancestor-or-self::ns1:businessEntity[#businessKey='uddi:testSignedProviderlastime'] and not (ancestor-or-self::ns1:businessService) and not (ancestor-or-self::ds:Signature)</ds:XPath>
</ds:Transform>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"/>
<ds:DigestValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#">something</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
something
</ds:SignatureValue>
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:X509Data xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:X509Certificate xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
something
</ds:X509Certificate>
</ds:X509Data>
<ds:KeyValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:RSAKeyValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:Modulus xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
something
</ds:Modulus>
<ds:Exponent xmlns:ds="http://www.w3.org/2000/09/xmldsig#">AQAB</ds:Exponent>
</ds:RSAKeyValue>
</ds:KeyValue>
</ds:KeyInfo>
</ds:Signature>
</ns1:businessEntity>
</ns1:save_business>
</soapenv:Body>
I guess you want this:
ancestor-or-self::*[local-name() = 'businessEntity']
Or a more precise:
ancestor-or-self::*
[local-name() = 'businessEntity' and namespace-uri() = 'urn:uddi-org:api_v3']
Related
I've been stuck for the last couple of days trying to figure out why the response which Im getting from the IdP is being rejected from the package I'm using. Im using this https://github.com/aacotroneo/laravel-saml2
This is the response that Im getting :
xml: """
<?xml version="1.0"?>
<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" Version="2.0" ID="vDJfB_2Fr9fGfh9izuYf6pSoE6q" IssueInstant="2020-11-04T08:55:23.144Z" InResp ▶
<saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">idP</saml:Issuer>
<samlp:Status>
<samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
</samlp:Status>
<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="kle-id.i4AcYYOSNJEX0biJ1lhh" IssueInstant="2020-11-04T08:55:23.302Z" Version="2.0">
<saml:Issuer>idP</saml:Issuer>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
<ds:Reference URI="#kle-id.i4AcYYOSNJEX0biJ1lhh">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>Bm0ARLP+duLFtM0UwVkXYr+W9PRSYYuW4sv0rzQsGlI=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>
RlvQm/VDU13e1oFU+y/0wr//bA6blrYBQER+57/hHq+SBRPDJl8hpEXnLaiv5AAEtzVteJrlhgc+
9YbTg8478l8hmBfVZVzlIa0POypWrNA8lwzhwDRAsQtbxypY3RPwKW0SSs6kq0K0EduxecG4grcl
1lWEpTRBtdv/NqVg6w8swSQzMXXf0GKjmqeagAqm3HeA6nSNc2T02ChwQ/78OZEbZjDaKj2Rqv2Y
1zqf/xyM2QZES3IlVfA5yekoJfG81sZYn5s+RiTsqFjAMvKrBsaPbEMZoT3ZcFQLY+/b08cTxCEM
RirLXRp86rAHhqps0+y1j9eFg0HWdvTO/3Ss0w==
</ds:SignatureValue>
<ds:KeyInfo>
<ds:X509Data>
<ds:X509Certificate>
DELETED FOR PRIVACY REASONS
</ds:X509Certificate>
</ds:X509Data>
<ds:KeyValue>
<ds:RSAKeyValue>
<ds:Modulus>
DELETED
</ds:Modulus>
<ds:Exponent>AQAB</ds:Exponent>
</ds:RSAKeyValue>
</ds:KeyValue>
</ds:KeyInfo>
</ds:Signature>
<saml:Subject>
<saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">DELETED FOR PRIVACY REASONS</saml:NameID>
<saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
<saml:SubjectConfirmationData Recipient="DELETED FOR PRIVACY REASONS" NotOnOrAfter="2020-11-04T09:00:23.305Z" InResponseTo="ONELOGIN_6134c96d0e247a491cc1a83286b4226c2d30004a"
</saml:SubjectConfirmation>
</saml:Subject>
<saml:Conditions NotBefore="2020-11-04T08:50:23.305Z" NotOnOrAfter="2020-11-04T09:00:23.305Z">
<saml:AudienceRestriction>
<saml:Audience>DELETED FOR PRIVACY REASONS</saml:Audience>
</saml:AudienceRestriction>
</saml:Conditions>
<saml:AuthnStatement SessionIndex="kle-id.i4AcYYOSNJEX0biJ1lhh" AuthnInstant="2020-11-04T08:36:22.912Z">
<saml:AuthnContext>
<saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified</saml:AuthnContextClassRef>
</saml:AuthnContext>
</saml:AuthnStatement>
</saml:Assertion>
</samlp:Response>
"""
Im not sure whats going on, but I kept tracing the validation and It seems to me that It rejects this response after checking for NotBefore attribute on line 359 at OneLogin\Saml2\Response.php
Can someone please help me to figure out what the hell is going on with it?
The idp is from PingFederate
From looking at the NotBefore and NotOnOrAfter timestamps in the Response, Ping is set to a 5min clock skew which is normal/default.
Without more specific error messages, it sounds like there is a clock drift issue between the IDP Server (PF) and your SP Application if your SP is complaining about the NotBefore. Ensure both servers have not only the proper time but also the proper timezone in the OS settings. You might need to restart PF to get it to pick-up any changes to the system time if you make any.
I have several user accounts in Office 365 tenant. Two of them are almost identical (have similar settings but different contact info and name).
I try to fetch information (such as all folders and items) in user's mailbox using GetFolder operation from EWS API that contains next body:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013"/>
<t:ExchangeImpersonation>
<t:ConnectingSID>
<t:PrimarySmtpAddress>Name.Surname#mydomain.onmicrosoft.com</t:PrimarySmtpAddress>
</t:ConnectingSID>
</t:ExchangeImpersonation>
</soap:Header>
<soap:Body>
<GetFolder xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<FolderShape>
<t:BaseShape>AllProperties</t:BaseShape>
<t:AdditionalProperties> </t:AdditionalProperties>
</FolderShape>
<FolderIds>
<t:DistinguishedFolderId Id="outbox"/>
</FolderIds>
</GetFolder>
</soap:Body>
</soap:Envelope>
I can successfully get info for one of these two mailboxes but when an error reply with the next body:
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorNonPrimarySmtpAddress</faultcode>
<faultstring xml:lang="en-US">The primary SMTP address must be specified when referencing a mailbox.</faultstring>
<detail>
<e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorNonPrimarySmtpAddress</e:ResponseCode>
<e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">The primary SMTP address must be specified when referencing a mailbox.</e:Message>
<t:MessageXml xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<t:Value Name="Primary"/>
</t:MessageXml>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
Why do I get such ErrorNonPrimarySmtpAddress error response? What can be the problem when I fetch data in the mailbox of the second user?
You need to use the primary SMTP address - I doubt Name.Surname#mydomain.onmicrosoft.com is the primary address.
Open the address book in Outlook (Ctrl+Shift+B), open the user, switch to the "E-mail Addresses" tab, look for the address with the "SMTP:" prefix (note the caps).
I'm using a FindItem call to get items (appointments) from Exchange Web Services (EWS). The properties which are fetched are the item Id and the EffectiveRights. The EffectiveRights property often does not contain the correct values. Sometimes, however, the values are correct (using the same code), but I don't know what causes this.
The Calendar folder I'm searching in is delegated with Author rights to the service user I authenticate with and it contains appointments of which this service user is the author of.
I'm using the ews-java-api library and the response traces show that this isn't a parsing bug.
The code used to retrieve the items:
ItemView view = new ItemView(100);
PropertySet propertySet = new PropertySet();
propertySet.add(ItemSchema.Id);
propertySet.add(ItemSchema.EffectiveRights);
view.setPropertySet(propertySet);
FolderId folderId = new FolderId(WellKnownFolderName.Calendar, Mailbox.getMailboxFromString(targetSmtpAddress));
FindItemsResults<Item> items = service.findItems(folderId, filter, view);
Item firstItem = items.getItems().get(0);
firstItem.getEffectiveRights(); // Returns NONE, READ. This is incorrect.
Item bindItem = Item.bind(service, firstItem.getId()); //
bindItem.getEffectiveRights(); // Returns NONE, READ, MODIFY, DELETE. This is correct.
The request trace:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010_SP2"></t:RequestServerVersion>
</soap:Header>
<soap:Body>
<m:FindItem Traversal="Shallow">
<m:ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
<t:AdditionalProperties>
<t:FieldURI FieldURI="item:ItemId"></t:FieldURI>
<t:FieldURI FieldURI="item:EffectiveRights"></t:FieldURI>
</t:AdditionalProperties>
</m:ItemShape>
<m:IndexedPageItemView MaxEntriesReturned="1000" Offset="0" BasePoint="Beginning"></m:IndexedPageItemView>
<m:Restriction>
<t:And>
<t:IsEqualTo>
<t:ExtendedFieldURI PropertySetId="039b4d91-2f03-44da-887c-aad704243ba8" PropertyName="SyncId" PropertyType="String"></t:ExtendedFieldURI>
<t:FieldURIOrConstant>
<t:Constant Value="syncID:330"></t:Constant>
</t:FieldURIOrConstant>
</t:IsEqualTo>
<t:IsGreaterThanOrEqualTo>
<t:FieldURI FieldURI="calendar:Start"></t:FieldURI>
<t:FieldURIOrConstant>
<t:Constant Value="2015-01-28T13:53:38Z"></t:Constant>
</t:FieldURIOrConstant>
</t:IsGreaterThanOrEqualTo>
</t:And>
</m:Restriction>
<m:ParentFolderIds>
<t:DistinguishedFolderId Id="calendar">
<t:Mailbox>
<t:EmailAddress>TARGETUSER#SMTP.ADDRESS</t:EmailAddress>
</t:Mailbox>
</t:DistinguishedFolderId>
</m:ParentFolderIds>
</m:FindItem>
</soap:Body>
</soap:Envelope>
The trace of a 'faulty' response:
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="14" MinorVersion="3" MajorBuildNumber="224" MinorBuildNumber="2" Version="Exchange2010_SP2" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<m:FindItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseMessages>
<m:FindItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:RootFolder IndexedPagingOffset="1000" TotalItemsInView="1868" IncludesLastItemInRange="false">
<t:Items>
<t:CalendarItem>
<t:ItemId Id="AAMkAGVlZmVlY2JjLTcxOTItNDBkYi1hOTljLTkwZjQwZjE4MTU1NQBGAAAAAADZ8IosQv76QbxS0r8FeFzgBwB25IsPmJcKTaP6zvCUqaybAAAAoIe5AAB25IsPmJcKTaP6zvCUqaybAABcSsgnAAA=" ChangeKey="DwAAABYAAAB25IsPmJcKTaP6zvCUqaybAABcS6ER"/>
<t:EffectiveRights>
<t:CreateAssociated>false</t:CreateAssociated>
<t:CreateContents>false</t:CreateContents>
<t:CreateHierarchy>false</t:CreateHierarchy>
<t:Delete>false</t:Delete>
<t:Modify>false</t:Modify>
<t:Read>true</t:Read>
<t:ViewPrivateItems>false</t:ViewPrivateItems>
</t:EffectiveRights>
</t:CalendarItem>
<t:CalendarItem>
<t:ItemId Id="AAMkAGVlZmVlY2JjLTcxOTItNDBkYi1hOTljLTkwZjQwZjE4MTU1NQBGAAAAAADZ8IosQv76QbxS0r8FeFzgBwB25IsPmJcKTaP6zvCUqaybAAAAoIe5AAB25IsPmJcKTaP6zvCUqaybAABcSsglAAA=" ChangeKey="DwAAABYAAAB25IsPmJcKTaP6zvCUqaybAABcS6EN"/>
<t:EffectiveRights>
<t:CreateAssociated>false</t:CreateAssociated>
<t:CreateContents>false</t:CreateContents>
<t:CreateHierarchy>false</t:CreateHierarchy>
<t:Delete>false</t:Delete>
<t:Modify>false</t:Modify>
<t:Read>true</t:Read>
<t:ViewPrivateItems>false</t:ViewPrivateItems>
</t:EffectiveRights>
</t:CalendarItem>
<!-- MORE ITEMS HERE... -->
</t:Items>
</m:RootFolder>
</m:FindItemResponseMessage>
</m:ResponseMessages>
</m:FindItemResponse>
</s:Body>
</s:Envelope>
I already found this blog post which seems somewhat related, but nothing more than that.
FindItems loads values from the contents table of a folder, rather than from the items themselves. Many times, with computed properties like EffectiveRights, a simplistic approach is used to populate the table to give an approximation. It seems like that's what's happening here. The comment in your code mentions that the value is correct after you Bind to the item (which loads values from the item itself).
I am using wso2esb-4.8.1,
I wish to change my request and response before sending to endpoint and client
so my request is
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header xmlns:env="http://eai.ttt.pp.hh" xmlns:open="http://www.oly.org/" xmlns:xsi="xsi">
<pr:authentication soapenv:her="http://schemas.xmlsoap.org/soap/her/next" soapenv:mustUnderstand="0" xmlns:pr="http://webservices.temp.com/ProxyService">
<pr:user>sec5</pr:user>
<pr:password>ss</pr:password>
</pr:authentication>
</soapenv:Header>
<soapenv:Body>
<open:clientRequest xmlns:open="http://www.oly.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:EaiEnvelope xmlns:env="http://eai.ttt.pp.hh">
<env:Language>en</env:Language>
<env:UserId>admc</env:UserId>
<env:Payload>
<ss:security xmlns:ss="http://eai.admc.kyt/security">
<ss:Request>
<ss:Operation_Name>securityrem</ss:Operation_Name>
<ss:customerID>
<ss:no>9875452</ss:no>
<ss:Service_Type>gsm</ss:Service_Type>
</ss:customerID>
<ss:customer>
<ss:isCredit>false</ss:isCredit>
<ss:Amount>100000</ss:Amount>
<ss:transaction_Id>4301298</ss:transaction_Id>
<ss:TransactionTypeID>228</ss:TransactionTypeID>
<!--<ss:DeductionPriorityCode>2</ss:DeductionPriorityCode>-->
</ss:customer>
</ss:Request>
</ss:security>
</env:Payload>
</env:EaiEnvelope>
</open:clientRequest>
</soapenv:Body>
</soapenv:Envelope>
I wish to change the ss:security element namespace with xmlns:emp="http://uri.open.gen/com" so my request should be change as per new Namespace its lke this
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header xmlns:env="http://eai.ttt.pp.hh" xmlns:open="http://www.oly.org/" xmlns:xsi="xsi">
<pr:authentication soapenv:her="http://schemas.xmlsoap.org/soap/her/next" soapenv:mustUnderstand="0" xmlns:pr="http://webservices.temp.com/ProxyService">
<pr:user>sec5</pr:user>
<pr:paempword>emp</pr:paempword>
</pr:authentication>
</soapenv:Header>
<soapenv:Body>
<open:clientRequest xmlns:open="http://www.oly.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:EaiEnvelope xmlns:env="http://eai.ttt.pp.hh">
<env:Language>en</env:Language>
<env:UserId>admc</env:UserId>
<env:Payload>
<emp:safety xmlns:emp="http://uri.open.gen/com">
<emp:Request>
<emp:Operation_Name>securityrem</emp:Operation_Name>
<emp:customerID>
<emp:no>9875452</emp:no>
<emp:Service_Type>gsm</emp:Service_Type>
</emp:customerID>
<emp:customer>
<emp:isCredit>false</emp:isCredit>
<emp:Amount>100000</emp:Amount>
<emp:transaction_Id>4301298</emp:transaction_Id>
<emp:TransactionTypeID>228</emp:TransactionTypeID>
<!--<emp:DeductionPriorityCode>2</emp:DeductionPriorityCode>-->
</emp:customer>
</emp:Request>
</emp:safety>
</env:Payload>
</env:EaiEnvelope>
</open:clientRequest>
</soapenv:Body>
</soapenv:Envelope>
So i have tried with xquery but its unable to do someone please responed for this
i have tried with this xquery
<x xmlns="http://ws.apache.org/ns/synapse">
declare namespace soapenv = "http://schemas.xmlsoap.org/soap/envelope";
declare namespace soap="http://schemas.xmlsoap.org/soap/envelope/";
declare namespace open="http://www.ffff.org/";
declare variable $emp as xs:string+:="http://uri.open.gen/com";
declare namespace env="http://eai.jj.mmm/Envelope";
declare variable $Request xs:string+ external;
declare variable $EaiEnvelope as document-node() external;
element{'open:clientRequest'}{
element{'*:EaiEnvelope'}{$EaiEnvelope//*:EaiEnvelope/*[not(local-name()='Payload')],
element{'*:Payload'}{
element{QName($emp,concat('emp',':','safety'))}
$Request//env:Payload/*[1]/*
}}
}
</x>
but its giving exception token is not specified
Thanks in advance
If XSLT 2.0 is an option for you (for example using saxon XSLT processor). You can apply this stylesheet to youe input:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ss="http://eai.admc.kyt/security"
xmlns:emp="http://uri.open.gen/com"
version="2.0">
<xsl:template match="node()|#*">
<xsl:copy>
<xsl:apply-templates select="node()|#*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ss:*">
<xsl:element name="emp:{local-name()}">
<xsl:apply-templates select="node()|#*"/>
</xsl:element>
</xsl:template>
<xsl:template match="#ss:*">
<xsl:attribute name="emp:{local-name()}">
<xsl:apply-templates select="node()|#*"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
Every attribute and element in http://eai.admc.kyt/security namespace in input will be in the other namespace in the output.
One note: it won't change in the comments
Here's an XQuery option...
XML Input
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header xmlns:env="http://eai.ttt.pp.hh" xmlns:open="http://www.oly.org/" xmlns:xsi="xsi">
<pr:authentication soapenv:her="http://schemas.xmlsoap.org/soap/her/next" soapenv:mustUnderstand="0" xmlns:pr="http://webservices.temp.com/ProxyService">
<pr:user>sec5</pr:user>
<pr:password>ss</pr:password>
</pr:authentication>
</soapenv:Header>
<soapenv:Body>
<open:clientRequest xmlns:open="http://www.oly.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:EaiEnvelope xmlns:env="http://eai.ttt.pp.hh">
<env:Language>en</env:Language>
<env:UserId>admc</env:UserId>
<env:Payload>
<ss:security xmlns:ss="http://eai.admc.kyt/security">
<ss:Request>
<ss:Operation_Name>securityrem</ss:Operation_Name>
<ss:customerID>
<ss:no>9875452</ss:no>
<ss:Service_Type>gsm</ss:Service_Type>
</ss:customerID>
<ss:customer>
<ss:isCredit>false</ss:isCredit>
<ss:Amount>100000</ss:Amount>
<ss:transaction_Id>4301298</ss:transaction_Id>
<ss:TransactionTypeID>228</ss:TransactionTypeID>
<!--<ss:DeductionPriorityCode>2</ss:DeductionPriorityCode>-->
</ss:customer>
</ss:Request>
</ss:security>
</env:Payload>
</env:EaiEnvelope>
</open:clientRequest>
</soapenv:Body>
</soapenv:Envelope>
XQuery
declare namespace emp="http://uri.open.gen/com";
declare namespace pr="http://webservices.temp.com/ProxyService";
declare namespace soapenv="http://schemas.xmlsoap.org/soap/envelope/";
declare namespace open="http://www.oly.org/";
declare namespace env="http://eai.ttt.pp.hh";
declare function local:ident($node as node()) {
if ($node instance of element()) then
if (namespace-uri($node) = 'http://eai.admc.kyt/security') then
local:change-ss($node)
else
element {$node/name()} {$node/#*,
for $child in $node/node() return local:ident($child)}
else if ($node instance of attribute()) then
if (namespace-uri($node) = 'http://eai.admc.kyt/security') then
local:change-ss($node)
else
$node
else if ($node instance of comment()) then
local:change-ss($node)
else
$node
};
declare function local:change-ss($node as node()) {
if ($node instance of element()) then
element {xs:QName(concat('emp:',$node/local-name()))} {
for $node in $node/(#*|node())
return
local:ident($node)
}
else if ($node instance of attribute()) then
attribute {xs:QName(concat('emp:',$node/local-name()))} {$node}
else if ($node instance of comment()) then
comment {replace($node,'(</?)ss:','$1emp:')}
else
$node
};
local:ident(/*)
XML Output
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<pr:authentication xmlns:pr="http://webservices.temp.com/ProxyService"
soapenv:her="http://schemas.xmlsoap.org/soap/her/next"
soapenv:mustUnderstand="0">
<pr:user>sec5</pr:user>
<pr:password>ss</pr:password>
</pr:authentication>
</soapenv:Header>
<soapenv:Body>
<open:clientRequest xmlns:open="http://www.oly.org/">
<env:EaiEnvelope xmlns:env="http://eai.ttt.pp.hh">
<env:Language>en</env:Language>
<env:UserId>admc</env:UserId>
<env:Payload>
<emp:security xmlns:emp="http://uri.open.gen/com">
<emp:Request>
<emp:Operation_Name>securityrem</emp:Operation_Name>
<emp:customerID>
<emp:no>9875452</emp:no>
<emp:Service_Type>gsm</emp:Service_Type>
</emp:customerID>
<emp:customer>
<emp:isCredit>false</emp:isCredit>
<emp:Amount>100000</emp:Amount>
<emp:transaction_Id>4301298</emp:transaction_Id>
<emp:TransactionTypeID>228</emp:TransactionTypeID>
<!--<emp:DeductionPriorityCode>2</emp:DeductionPriorityCode>-->
</emp:customer>
</emp:Request>
</emp:security>
</env:Payload>
</env:EaiEnvelope>
</open:clientRequest>
</soapenv:Body>
</soapenv:Envelope>
The 2 XQuery functions can be combined to make it smaller, but I thought it was a little more readable.
I have a problem in parsing XML data into my browser. Can some one tell me if this is fine:
<?xml version="1.0"?>
<nutrition><daily-values><total-fat units="g">65</total-fat><saturated-fat units="g">20</saturated-fat><cholesterol units="mg">300</cholesterol><sodium units="mg">2400</sodium><carb units="g">300</carb><fiber units="g">25</fiber><protein units="g">50</protein></daily-values><food><name>Cole Slaw</name><mfr>Fresh Quick</mfr><serving units=" cup">1.5</serving><calories total="20" fat="0"/><total-fat>0</total-fat><saturated-fat>0</saturated-fat><cholesterol>0</cholesterol><sodium>15</sodium><carb>5</carb><fiber>2</fiber><protein>1</protein><vitamins><a>30</a><c>45</c></vitamins><minerals><ca>4</ca><fe>2</fe></minerals></food><food><name>Eggs</name><mfr>Goodpath</mfr><serving units="g">50</serving><calories total="70" fat="40"/><total-fat>4.5</total-fat><saturated-fat>1.5</saturated-fat><cholesterol>215</cholesterol><sodium>65</sodium><carb>1</carb><fiber>0</fiber><protein>6</protein><vitamins><a>6</a><c>0</c></vitamins><minerals><ca>2</ca><fe>4</fe></minerals></food><food><name>Hazelnut Spread</name><mfr>Ferreira</mfr><serving units="tbsp">2</serving><calories total="200" fat="90"/><total-fat>10</total-fat><saturated-fat>2</saturated-fat><cholesterol>0</cholesterol><sodium>20</sodium><carb>23</carb><fiber>2</fiber><protein>3</protein><vitamins><a>0</a><c>0</c></vitamins><minerals><ca>6</ca><fe>4</fe></minerals</food><food><name>Potato Chips</name><mfr>Lees</mfr><serving units="g">28</serving><calories total="150" fat="90"/><total-fat>10</total-fat><saturated-fat>3</saturated-fat><cholesterol>0</cholesterol><sodium>180</sodium><carb>15</carb><fiber>1</fiber><protein>2</protein><vitamins><a>0</a><c>10</c></vitamins><minerals><ca>0</ca><fe>0</fe></minerals></food><food><name>Soy Patties, Grilled</name><mfr>Gardenproducts</mfr><serving units="g">96</serving><calories total="160" fat="45"/><total-fat>5</total-fat><saturated-fat>0</saturated-fat><cholesterol>0</cholesterol><sodium>420</sodium><carb>10</carb><fiber>4</fiber><protein>9</protein><vitamins><a>0</a><c>0</c></vitamins><minerals><ca>0</ca><fe>0</fe></minerals></food><food><name>Truffles, Dark Chocolate</name><mfr>Lyndon's</mfr><serving units="g">39</serving><calories total="220" fat="170"/><total-fat>19</total-fat><saturated-fat>14</saturated-fat><cholesterol>25</cholesterol><sodium>10</sodium><carb>16</carb><fiber>1</fiber><protein>1</protein><vitamins><a>0</a><c>0</c></vitamins><minerals><ca>0</ca><fe>0</fe></minerals></food></nutrition>
In the food element with the name of <name>Hazelnut Spread</name> You are missing a >
here:
<fe>4</fe></minerals</food>
should be:
<fe>4</fe></minerals></food>
If you copy this code and save it to xml and open in browser, you will see, that in one place there is </minerals</food> (mistyped tag)
this tag not closed "<fe>4</fe></minerals"
Change with below code
<?xml version="1.0"?>
<nutrition>
<daily-values>
<total-fat units="g">65</total-fat>
<saturated-fat units="g">20</saturated-fat>
<cholesterol units="mg">300</cholesterol>
<sodium units="mg">2400</sodium>
<carb units="g">300</carb>
<fiber units="g">25</fiber>
<protein units="g">50</protein>
</daily-values>
<food>
<name>Cole Slaw</name>
<mfr>Fresh Quick</mfr>
<serving units=" cup">1.5</serving>
<calories total="20" fat="0"/>
<total-fat>0</total-fat>
<saturated-fat>0</saturated-fat>
<cholesterol>0</cholesterol>
<sodium>15</sodium>
<carb>5</carb>
<fiber>2</fiber>
<protein>1</protein>
<vitamins>
<a>30</a>
<c>45</c>
</vitamins>
<minerals>
<ca>4</ca>
<fe>2</fe>
</minerals>
</food>
<food>
<name>Eggs</name>
<mfr>Goodpath</mfr>
<serving units="g">50</serving>
<calories total="70" fat="40"/>
<total-fat>4.5</total-fat>
<saturated-fat>1.5</saturated-fat>
<cholesterol>215</cholesterol>
<sodium>65</sodium>
<carb>1</carb>
<fiber>0</fiber>
<protein>6</protein>
<vitamins>
<a>6</a>
<c>0</c>
</vitamins>
<minerals>
<ca>2</ca>
<fe>4</fe>
</minerals>
</food>
<food>
<name>Hazelnut Spread</name>
<mfr>Ferreira</mfr>
<serving units="tbsp">2</serving>
<calories total="200" fat="90"/>
<total-fat>10</total-fat>
<saturated-fat>2</saturated-fat>
<cholesterol>0</cholesterol>
<sodium>20</sodium>
<carb>23</carb>
<fiber>2</fiber>
<protein>3</protein>
<vitamins>
<a>0</a>
<c>0</c>
</vitamins>
<minerals>
<ca>6</ca>
<fe>4</fe>
</minerals>
</food>
<food>
<name>Potato Chips</name>
<mfr>Lees</mfr>
<serving units="g">28</serving>
<calories total="150" fat="90"/>
<total-fat>10</total-fat>
<saturated-fat>3</saturated-fat>
<cholesterol>0</cholesterol>
<sodium>180</sodium>
<carb>15</carb>
<fiber>1</fiber>
<protein>2</protein>
<vitamins>
<a>0</a>
<c>10</c>
</vitamins>
<minerals>
<ca>0</ca>
<fe>0</fe>
</minerals>
</food>
<food>
<name>Soy Patties, Grilled</name>
<mfr>Gardenproducts</mfr>
<serving units="g">96</serving>
<calories total="160" fat="45"/>
<total-fat>5</total-fat>
<saturated-fat>0</saturated-fat>
<cholesterol>0</cholesterol>
<sodium>420</sodium>
<carb>10</carb>
<fiber>4</fiber>
<protein>9</protein>
<vitamins>
<a>0</a>
<c>0</c>
</vitamins>
<minerals>
<ca>0</ca>
<fe>0</fe>
</minerals>
</food>
<food>
<name>Truffles, Dark Chocolate</name>
<mfr>Lyndon's</mfr>
<serving units="g">39</serving>
<calories total="220" fat="170"/>
<total-fat>19</total-fat>
<saturated-fat>14</saturated-fat>
<cholesterol>25</cholesterol>
<sodium>10</sodium>
<carb>16</carb>
<fiber>1</fiber>
<protein>1</protein>
<vitamins>
<a>0</a>
<c>0</c>
</vitamins>
<minerals>
<ca>0</ca>
<fe>0</fe>
</minerals>
</food>
</nutrition>