XSL Transform - Remove Parent Node - soap

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:enterprise.soap.sforce.com">
<soapenv:Body>
<upsertResponse>
<result>
<created>true</created>
<id>0011</id>
<success>true</success>
</result>
<result>
<created>false</created>
<id>0012</id>
<success>true</success>
</result>
</upsertResponse>
</soapenv:Body>
</soapenv:Envelope>
**How can I transform this to**
<upsertResponse>
<result>
<created>true</created>
<id>0011</id>
<success>true</success>
</result>
<result>
<created>false</created>
<id>0012</id>
<success>true</success>
</result>
</upsertResponse>

This is an example of XSL that takes the first child of first child of root and makes it root node of new XML:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:copy-of select="./*[1]/*[1]/*[1]" />
</xsl:template>
</xsl:stylesheet>
Please note that you can take only one node and not multiple nodes since placing few nodes as root of XML is not valid.

Use an <xsl:match> to select the <upsertResponse> element, then put an <xsl:copy> inside of it. That should do the trick. Sorry I don't have the exact syntax, but hopefully this points you in the right direction.

Related

Adjust Dita-OT plugin to output PDF wireframe with all blocks solid border

I'm interested to output solid black border surrounding all fo:blocks to aid in viewing where the borders are between elements displayed in a pdf output.
I would like to apply a transformation at the end of dita-ot plugin that applies the borders. I can fiddle with the following xsl however I'm not sure how to apply the xlst at the end of a dita-ot process.
<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet exclude-result-prefixes="xs ditaarch opentopic e" version="2.0" xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/" xmlns:e="com.docdept.pdf" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:opentopic="http://www.idiominc.com/opentopic" xmlns:opentopic-func="http://www.idiominc.com/opentopic/exsl/function" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="#*|*|processing-instruction()|comment()">
<xsl:copy>
<xsl:apply-templates select="*|#*|text()|processing-instruction()|comment()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="fo:block">
<xsl:copy>
<xsl:copy-of select="#*"/>
<xsl:attribute name="border-style">solid</xsl:attribute>
<xsl:attribute name="border-width">0.5pt</xsl:attribute>
<xsl:attribute name="border-color">black</xsl:attribute>
<xsl:apply-templates select="*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
I thought perhaps the following to apply wireframe.xsl at the end of the process but this does not work.
<?xml version='1.0' encoding='UTF-8'?>
<plugin id="com.docdept.pdf">
<require plugin="org.dita.pdf2" />
<feature extension="dita.conductor.transtype.check" value="adjust-pdf" />
<feature extension="dita.transtype.print" value="docdept-pdf" />
<feature extension="dita.conductor.target.relative" file="integrator.xml" />
<feature extension="dita.xsl.pdf" file="xsl/fo/wireframe.xsl"/>
</plugin>
I'm seeing that it's better to associate borders of different colors to the attribute sets so there is visual reference that can also be searched for by color name within the fo output.
<xsl:attribute name="border">1mm thin solid</xsl:attribute>
<xsl:attribute name="border-color">GOLD</xsl:attribute>

Extended property in EWS

I am interacting with exchange to extract emails having particular extended property. I am able to fetch email that I have sent with newly created extended properties, but when I reply to the emails, these properties are not preserved..Is this normal behavior? Is there anyway to work around it?
The code I am using to send and fetch email for now is as below
To send email with extended property
`<?xml version="1.0" encoding="utf-8"?>
<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"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010" />
</soap:Header>
<soap:Body>
<m:CreateItem MessageDisposition="SendAndSaveCopy">
<m:SavedItemFolderId>
<t:DistinguishedFolderId Id="sentitems" />
</m:SavedItemFolderId>
<m:Items>
<t:Message>
<t:Subject>Greetings</t:Subject>
<t:Body BodyType="Text">Message with extended property attached</t:Body>
<t:ExtendedProperty>
<t:ExtendedFieldURI PropertySetId="c11ff724-aa03-4555-9952-8fa248a11c3e"
PropertyName="extended_property_name" PropertyType="String" />
<t:Value>NEWVALUE</t:Value>
</t:ExtendedProperty>
<t:ToRecipients>
<t:Mailbox>
<t:EmailAddress>test#cisco.com</t:EmailAddress>
</t:Mailbox>
</t:ToRecipients>
</t:Message>
</m:Items>
</m:CreateItem>
</soap:Body>
</soap:Envelope>`
Fetching email with extended property
`<?xml version="1.0" encoding="UTF-8" ?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:mes="http://schemas.microsoft.com/exchange/services/2006/messages">
<soapenv:Header>
<typ:RequestServerVersion Version="Exchange2007_SP1"/>
</soapenv:Header>
<soapenv:Body>
<mes:FindItem Traversal="Shallow">
<mes:ItemShape>
<typ:BaseShape>Default</typ:BaseShape>
<typ:IncludeMimeContent>false</typ:IncludeMimeContent>
<typ:BodyType>Best</typ:BodyType>
</mes:ItemShape>
<mes:IndexedPageItemView MaxEntriesReturned="10" Offset="0" BasePoint="Beginning"/>
<mes:GroupBy Order="Ascending">
<typ:FieldURI FieldURI="item:DateTimeReceived" />
<typ:AggregateOn Aggregate="Maximum">
<typ:FieldURI FieldURI="item:ItemId"/>
</typ:AggregateOn>
</mes:GroupBy>
<mes:Restriction>
<typ:IsEqualTo>
<typ:ExtendedFieldURI PropertySetId="c11ff724-aa03-4555-9952-8fa248a11c3e" PropertyName="extended_property_name" PropertyType="String" />
<typ:FieldURIOrConstant>
<typ:Constant Value="NEWVALUE" />
</typ:FieldURIOrConstant>
</typ:IsEqualTo>
</mes:Restriction>
<mes:ParentFolderIds>
<!--You have a CHOICE of the next 2 items at this level-->
<typ:FolderId Id="[Process.Variables.Completed Id]"
ChangeKey="[Process.Variables.Completed ChangeKey]"/>
</mes:ParentFolderIds>
</mes:FindItem>
</soapenv:Body>
</soapenv:Envelope>`
Any Help will be greatly appreciated!
Thanks
Yes that is normal the extended properties your setting are for the message your sending, the response is a brand new message and won't contain any custom properties you have set (this would actually be more of a problem if it did). If your trying to correlate response and reply then you should look at the InReplyto,Referances or ConversationId eg http://blog.mailgun.com/tracking-replies-in-mailgun-or-any-other-email/
cheers
Glen

current-dateTime() to number

I need to convert the current-dateTime() to a number, because the output only allows an integer (or long). How can I do that?
My desired output:
<?xml version="1.0" encoding="utf-8"?>
<currentDate>NaN</currentDate>
My XSLT:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" version="2.0">
<xsl:output method="xml" encoding="utf-8" indent="yes"/>
<xsl:variable name="version" select="'1.0'"/>
<xsl:template match="/">
<xsl:element name="currentDate">
<xsl:value-of select="number(current-dateTime())"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
But I get this here:
<?xml version="1.0" encoding="utf-8"?>
<currentDate>NaN</currentDate>
When I remove the number() I do get the timestamp, but I need to have a clean number.
<?xml version="1.0" encoding="utf-8"?>
<currentDate>2014-01-15T07:01:02.526+01:00</currentDate>
How can I convert the timestamp to a clean number?
As mentioned, to convert "2014-01-15T07:01:02.526+01:00" to "20140115070102526" you can use the translate() function (this would work with XSLT 1.0):
<xsl:value-of select="translate(substring(string(current-dateTime()), 1, 23), '-:T.', '')"/>
Alternatively, you can calculate the duration between the current date and time and an arbitrary start and divide this duration by a millisecond to get the number of milliseconds since that date:
<xsl:value-of select="(current-dateTime() - xs:dateTime('1971-01-01T00:00:00')) div xs:dayTimeDuration('PT0.001S')"/>
In XSLT 2.0, you can use the format-dateTime() function and reformat the date: just use a picture parameter with no separators.
Alternatively - assuming all component values are already padded with zeros to maintain a fixed length - you could simply translate the separator characters away.

Monitoring multiple folders in one 'syncFolderItems' operation?

Is it possible to monitor several folders in one 'syncFolderItems' operation?
I tried it, but It doesn't seem to work.
For example, this:
<?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:Body>
<SyncFolderItems xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
<ItemShape>
<t:BaseShape>Default</t:BaseShape>
</ItemShape>
<SyncFolderId>
<t:DistinguishedFolderId Id="drafts"/>
<t:DistinguishedFolderId Id="inbox"/>
</SyncFolderId>
<MaxChangesReturned>500</MaxChangesReturned>
</SyncFolderItems>
</soap:Body>
</soap:Envelope>
doesn't work :(
is it possible?
Thanks :)
I know this is very old question but, still it is important for other user so i am answering.
No it is not Possible
SyncFolderId can have one child tag FolderID or DistinguishedFolderID
<SyncFolderId>
<FolderId/>
</SyncFolderId>
<SyncFolderId>
<DistinguishedFolderId/>
</SyncFolderId>
reference link http://msdn.microsoft.com/en-us/library/exchange/aa580296%28v=exchg.80%29.aspx

Xml parsing problem

I have an xml like this
<?xml version="1.0" encoding="UTF-8" ?>
<product>
<productname> ----->Dynamic node
</title>
</price>
</desc>
</productname>
<productname> ---->Dynamic node
</title>
</price>
</desc>
</productname>
</product>
productname node is dynamic depends on our request.
how to get the name of the element (productname) and the values of an element.
I use touch xml by Jonathan Wight.