Remove attribute from all nodes of XML in SQL - sql-server

How can the remove the attribute "CRS" from all the nodes of the XML through T-sql. Looking to remove the attribute "CRS" if exist in the XML.
<list>
<group id="12345">
<entry id="1" type="Audio" lang="en-us">
<p data-its-style="">
<audio xmlns="http://www.imsglobal.org/xsd/imsqtiv2p2_html5_v1p0" class="sound_explicit">
<source crs="test1_en.ogg" type="audio/ogg; " src="1234.ogg" />
<source crs="test1_en.m4a" type="audio/mp4;" src="4567.mp4" />
</audio>
</p>
</entry>
</group>
<group id="67890">
<entry id="4" type="Audio" lang="es-mx">
<p data-its-style="">
<audio xmlns="http://www.imsglobal.org/xsd/imsqtiv2p2_html5_v1p0" class="sound_explicit">
<source crs="test4_en.ogg" type="audio/ogg; " src="1234.ogg" />
<source crs="test4_en.m4a" type="audio/mp4;" src="4567.mp4" />
</audio>
</p>
</entry>
</group>

this should do the trick
DECLARE #xml XML = '<list>
<group id="12345">
<entry id="1" type="Audio" lang="en-us">
<p data-its-style="">
<audio xmlns="http://www.imsglobal.org/xsd/imsqtiv2p2_html5_v1p0" class="sound_explicit">
<source crs="test1_en.ogg" type="audio/ogg; " src="1234.ogg" />
<source crs="test1_en.m4a" type="audio/mp4;" src="4567.mp4" />
</audio>
</p>
</entry>
</group>
<group id="67890">
<entry id="4" type="Audio" lang="es-mx">
<p data-its-style="">
<audio xmlns="http://www.imsglobal.org/xsd/imsqtiv2p2_html5_v1p0" class="sound_explicit">
<source crs="test4_en.ogg" type="audio/ogg; " src="1234.ogg" />
<source crs="test4_en.m4a" type="audio/mp4;" src="4567.mp4" />
</audio>
</p>
</entry>
</group>
</list>'
/*Before*/
SELECT #xml
/*Delete*/
SET #xml.modify ('declare namespace ns="http://www.imsglobal.org/xsd/imsqtiv2p2_html5_v1p0"; delete list/group/entry/p/ns:audio/ns:source/#crs')
/*After*/
SELECT #xml

Related

Position Outlook Add-In button on the `AppointmentOrganizerCommandSurface`

I am trying to add a button to the AppointmentOrganizerCommandSurface in Outlook just like Giphy is added in this image, but instead, my My Office Add-in is added to the menu.
I would like to add an action button with my custom icon next to the Giphy action.
I tried manipulating manifest.xml. I went through the documentation and followed the steps, but I was unable to figure out what is going on.
Here is the manifest:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0" xsi:type="MailApp">
<Id>61262617-dad8-4e84-a9e4-89b1bab3e6e7</Id>
<Version>1.0.0.0</Version>
<ProviderName>Contoso</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="My Office Add-In"/>
<Description DefaultValue="A template to get started."/>
<IconUrl DefaultValue="https://localhost:3000/assets/icon-64.png"/>
<HighResolutionIconUrl DefaultValue="https://localhost:3000/assets/icon-128.png"/>
<SupportUrl DefaultValue="https://www.contoso.com/help"/>
<AppDomains>
<AppDomain>https://www.contoso.com</AppDomain>
</AppDomains>
<Hosts>
<Host Name="Mailbox"/>
</Hosts>
<Requirements>
<Sets>
<Set Name="Mailbox" MinVersion="1.1"/>
</Sets>
</Requirements>
<FormSettings>
<Form xsi:type="ItemRead">
<DesktopSettings>
<SourceLocation DefaultValue="https://localhost:3000/taskpane.html"/>
<RequestedHeight>250</RequestedHeight>
</DesktopSettings>
</Form>
</FormSettings>
<Permissions>ReadWriteItem</Permissions>
<Rule xsi:type="RuleCollection" Mode="Or">
<Rule xsi:type="ItemIs" ItemType="Message" FormType="Read"/>
</Rule>
<DisableEntityHighlighting>false</DisableEntityHighlighting>
<VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
<Requirements>
<bt:Sets DefaultMinVersion="1.3">
<bt:Set Name="Mailbox"/>
</bt:Sets>
</Requirements>
<Hosts>
<Host xsi:type="MailHost">
<DesktopFormFactor>
<FunctionFile resid="Commands.Url"/>
<ExtensionPoint xsi:type="AppointmentOrganizerCommandSurface">
<OfficeTab id="TabDefault">
<Group id="msgReadGroup">
<Label resid="GroupLabel"/>
<Control xsi:type="Button" id="msgReadOpenPaneButton">
<Label resid="TaskpaneButton.Label"/>
<Supertip>
<Title resid="TaskpaneButton.Label"/>
<Description resid="TaskpaneButton.Tooltip"/>
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16"/>
<bt:Image size="32" resid="Icon.32x32"/>
<bt:Image size="80" resid="Icon.80x80"/>
</Icon>
<Action xsi:type="ShowTaskpane">
<SourceLocation resid="Taskpane.Url"/>
</Action>
</Control>
<Control xsi:type="Button" id="ActionButton">
<Label resid="ActionButton.Label"/>
<Supertip>
<Title resid="ActionButton.Label"/>
<Description resid="ActionButton.Tooltip"/>
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16"/>
<bt:Image size="32" resid="Icon.32x32"/>
<bt:Image size="80" resid="Icon.80x80"/>
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>action</FunctionName>
</Action>
</Control>
</Group>
</OfficeTab>
</ExtensionPoint>
</DesktopFormFactor>
</Host>
</Hosts>
<Resources>
<bt:Images>
<bt:Image id="Icon.16x16" DefaultValue="https://localhost:3000/assets/icon-16.png"/>
<bt:Image id="Icon.32x32" DefaultValue="https://localhost:3000/assets/icon-32.png"/>
<bt:Image id="Icon.80x80" DefaultValue="https://localhost:3000/assets/icon-80.png"/>
</bt:Images>
<bt:Urls>
<bt:Url id="Commands.Url" DefaultValue="https://localhost:3000/commands.html"/>
<bt:Url id="Taskpane.Url" DefaultValue="https://localhost:3000/taskpane.html"/>
</bt:Urls>
<bt:ShortStrings>
<bt:String id="GroupLabel" DefaultValue="Contoso Add-in"/>
<bt:String id="TaskpaneButton.Label" DefaultValue="Show Taskpane"/>
<bt:String id="ActionButton.Label" DefaultValue="Perform an action"/>
</bt:ShortStrings>
<bt:LongStrings>
<bt:String id="TaskpaneButton.Tooltip" DefaultValue="Opens a pane displaying all available properties."/>
<bt:String id="ActionButton.Tooltip" DefaultValue="Perform an action when clicked."/>
</bt:LongStrings>
</Resources>
</VersionOverrides>
</OfficeApp>
Thank you in advance.
You need to pin your add-in in the outlook to acheive the same.
You can pin an add-in so it's easily available when you're composing an email message.
Select Settings> View all Outlook settings > Mail > Customize actions.
Select the check box for the add-in that you want to see when you’re composing a message.

Log4j generate different files with the same content

I'm working with a Java application that integrates log4j. For a new development I would need that instead of generating a file I will generate two, one per country that is accessed from the application web. Both would have the same log records that are found throughout my application.
I configured the configuration using an .xml file:
<!-- Appenders -->
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="jeveris: %d{dd MMM yyyy HH:mm:ss,SSS} %-5p %c - %m%n" />
</layout>
</appender>
<appender name="One-Console" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="Console.log" />
<param name="Append" value="true" />
<param name="MaxFileSize" value="2MB" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d{dd MMM yyyy HH:mm:ss,SSS} %-5p %c - %m%n" />
</layout>
</appender>
<category name="com.example.one.web">
<level value="debug" />
<appender-ref ref="One-Console" />
</category>
<root>
<appender-ref ref="console" />
<level value="debug" />
</root>
</log4j:configuration>
Could someone guide me, tell me if it is possible or help me find the solution?
Thank you.
If you want 2+ log files that will print the same content, then you could fine 2 different files in your tag like so:
<configuration status="OFF">
<Properties>
<Property name="log-path">/your/file/path/</Property>
<Property name="log-country-name1">Country1</Property>
<Property name="log-country-name2">Country2</Property>
<!-- more if necessary -->
<Property name="log-pattern">%d{ISO8601} %-5p [%t|%c{1}] %m\n</Property>
<Property name="rollover-strategy-max">5</Property>
<Property name="rolling-size-based">10 MB</Property>
</Properties>
<appenders>
<!--uncomment following if want to print to console as well -->
<!-- <Console name="Console" target="SYSTEM_OUT">
<PatternLayout>
<pattern>${log-pattern}</pattern>
</PatternLayout>
</Console> -->
<RollingFile name="INFO" fileName="${log-path}/${log-country-name1}-logger.log" filePattern="${log-path}/${log-project-name}-debug-%d-%i.log.zip">
<PatternLayout>
<pattern>${log-pattern}</pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="${rolling-size-based}" />
</Policies>
<DefaultRolloverStrategy max="${rollover-strategy-max}" />
</RollingFile>
<RollingFile name="INFO" fileName="${log-path}/UpdaterLocal-logger.log" filePattern="${log-path}/${log-country-name2}-debug-%d-%i.log.zip">
<PatternLayout>
<pattern>${log-pattern}</pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="${rolling-size-based}" />
</Policies>
<DefaultRolloverStrategy max="${rollover-strategy-max}" />
</RollingFile>
</appenders>
<Loggers>
<logger name="io.switchfour" level="trace" additivity="false">
<AppenderRef ref="INFO" level="info" />
</logger>
</Loggers>
The above will create /your/file/path/Country1-logger.log and /your/file/path/Country2-logger.log and will write all entries that are INFO or higher to both files. Your log file should be identical.

ant run target if file has specifc suffix

I pass a filename to ant script via
ant -Dfilepath=/foo/bar/foobar.suffix
I want to copy it to a destination and if it is a .js file generate a compiled version of it.
This works but currently the compile task runs on all files not just .js file.
How do I exclude non .js files in the "runjscompile" task?
In a fileset I would do this (but I don't get how to apply this on the task):
<fileset dir="${foo}" casesensitive="yes">
<exclude name="**/*.min.js" />
<include name="**/*.js" />
</fileset>
My build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="test" basedir="." default="build">
<taskdef name="jscomp" classname="com.google.javascript.jscomp.ant.CompileTask" classpath="/home/bar/bin/compiler.jar" />
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="/usr/share/java/ant-contrib.jar" />
</classpath>
</taskdef>
<property name="serverRoot" value="/home/bar/server/public_html" />
<property name="foo" value="${serverRoot}/foo/" />
<property name="workspaceRoot"
value="/home/bar/Zend/workspaces/DefaultWorkspace/" />
<property name="foo_service" value="${workspaceRoot}/foo_service/" />
<property name="filepath" value="${filepath}" />
<target name="build" depends="transferFile, runjscompile" />
<target name="transferFile" description="overwrite old file">
<basename property="filename" file="${filepath}" />
<dirname property="path" file="${filepath}" />
<pathconvert property="path.fragment" pathsep="${line.separator}">
<propertyresource name="path" />
<mapper type="regexp" from="^/[^/]+/(.*)" to="\1" />
</pathconvert>
<echo message="copy ${workspaceRoot}${filepath} to ${foo}${path.fragment}${filename}" />
<copy file="${workspaceRoot}${filepath}" tofile="${foo}${path.fragment}${filename}"
overwrite="true" force="true" />
<property name="destFile" value="${foo}${path.fragment}${filename}" />
</target>
<target name="runjscompile">
<echo message="compile ${destFile}" />
<basename property="file" file="${destFile}" />
<basename property="prefix" file="${destFile}" suffix=".js" />
<dirname property="directory" file="${destFile}" />
<echo message="Compressing file ${file} to ${directory}/${prefix}.min.js" />
<jscomp compilationLevel="simple" debug="false" output="${directory}/${prefix}.min.js" forceRecompile="true">
<sources dir="${directory}">
<file name="${file}" />
</sources>
</jscomp>
</target>
</project>
Add another target which checks the file suffix with a <condition> and sets a property if it matches, then make the jscompile target conditional on that. Following your fileset example you probably want something like:
<target name="check.js">
<condition property="do.jscompile">
<!-- check for filepath that ends .js but not .min.js -->
<matches string="${filepath}" pattern=".*(?<!\.min)\.js$$" />
</condition>
</target>
<target name="build" depends="check.js, transferFile, runjscompile" />
<target name="runjscompile" if="do.jscompile">

.bat file wont save a .log file when triggered in VBA

Ok, so this is a somewhat complicated question, but hopefully somebody can help me out. I created a .bat file to help with batch process data uploads to SalesForce servers. I then tied excel macros to the .bat files by having the .bat files called in Excel VBA.
Here's my problem: Whenever the .bat files are called in VBA, the .log file isn't saved - it's not even executed (almost like the line of code didn't exist in the .bat file).
Now here's the weird part: if I just click on the .bat file to begin the upload process -- as opposed to calling the .bat from within VBA -- the .log file is overwritten and a new one is created.
How can I get the .bat file to save a .log regardless of whether its fired simply by clicking on the .bat file, or from within VBA? This is very frustrating - any and all help is greatly appreciated. Thank you.
Here's my MS-DOS (batch) code:
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org /dtd/spring-beans.dtd">
<beans>
<bean id="Update_Listing_Val_FNMA" class="com.salesforce.dataloader.process.ProcessRunner" singleton="false">
<description>Created by Dataloader Cliq.</description>
<property name="name" value="Update_Listing_Val_FNMA"/>
<property name="configOverrideMap">
<map>
<entry key="dataAccess.name" value="M:\My Folder\CSV Files\salesforce.com\Apex Data Loader 22.0\cliq_process\Update_Listing_Val_FNMA\read\Update_Listing_Val_FNMA.csv"/>
<entry key="dataAccess.readUTF8" value="true"/>
<entry key="dataAccess.type" value="csvRead"/>
<entry key="dataAccess.writeUTF8" value="true"/>
<entry key="process.enableExtractStatusOutput" value="true"/>
<entry key="process.enableLastRunOutput" value="true"/>
<entry key="process.lastRunOutputDirectory" value="M:\My Folder\CSV Files\salesforce.com\Apex Data Loader 22.0\cliq_process\Update_Listing_Val_FNMA\log"/>
<entry key="process.mappingFile" value="M:\My Folder\CSV Files\salesforce.com\Apex Data Loader 22.0\cliq_process\Update_Listing_Val_FNMA\config\Update_Listing_Val_FNMA.sdl"/>
<entry key="process.operation" value="update"/>
<entry key="process.statusOutputDirectory" value="M:\My Folder\CSV Files\salesforce.com\Apex Data Loader 22.0\cliq_process\Update_Listing_Val_FNMA\log"/>
<entry key="sfdc.bulkApiCheckStatusInterval" value="5000"/>
<entry key="sfdc.bulkApiSerialMode" value="5000"/>
<entry key="sfdc.debugMessages" value="false"/>
<entry key="sfdc.enableRetries" value="true"/>
<entry key="sfdc.endpoint" value="https://www.salesforce.com/services/Soap/u/22.0"/>
<entry key="sfdc.entity" value="QA_FNMA__c"/>
<entry key="sfdc.extractionRequestSize" value="500"/>
<entry key="sfdc.insertNulls" value="false"/>
<entry key="sfdc.loadBatchSize" value="100"/>
<entry key="sfdc.maxRetries" value="3"/>
<entry key="sfdc.minRetrySleepSecs" value="2"/>
<entry key="sfdc.noCompression" value="false"/>
<entry key="sfdc.password" value="XXXXXXXXXXXXXXXXXX"/>
<entry key="sfdc.proxyHost" value=""/>
<entry key="sfdc.proxyNtlmDomain" value=""/>
<entry key="sfdc.proxyPassword" value=""/>
<entry key="sfdc.proxyPort" value=""/>
<entry key="sfdc.proxyUsername" value=""/>
<entry key="sfdc.timeoutSecs" value="60"/>
<entry key="sfdc.useBulkApi" value="false"/>
<entry key="sfdc.username" value="XXXXXXXXXXXXXXXXXX"/>
</map>
</property>
</bean>
</beans>
** EDIT - 2/13/14 1649 **
Here's the call from VBA part:
Shell "M:\My Folder\XXXXXXXXXXXX\CSV Files\salesforce.com\Apex Data Loader 22.0\cliq_process\O PKG Status\Update_O_PKG_Status_REAC\Update_O_PKG_Status_REAC.bat"
Application.Wait (Now + TimeValue("0:00:12"))
Sheets("sheet5").Select
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="M:\My Folder\XXXXXXXXXXXXXXX\CSV Files\salesforce.com\Apex Data Loader 22.0\cliq_process\O PKG Status\Update_O_PKG_Status_FNMA_Reactive\read\Update_O_PKG_Status_FNMA_Reactive", FileFormat:=xlCSV
newFileName = "FREAC O Pkg" & Format(Now, " MM-DD HHMM") & ".csv"
** EDIT - 2/18/14 1221 **
Here's the log-conf file; it's an XML doc.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration>
<appender name="fileAppender" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="log/sdl.log" />
<param name="Append" value="true" />
<param name="MaxFileSize" value="100KB" />
<param name="MaxBackupIndex" value="1" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%t] %C{2} %M (%F:%L) - %m%n"/>
</layout>
</appender>
<appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%t] %C{2} %M (%F:%L) - %m%n"/>
</layout>
</appender>
<category name="org.apache.log4j.xml">
<priority value="warn" />
<appender-ref ref="fileAppender" />
<appender-ref ref="STDOUT" />
</category>
<logger name="org.apache" >
<level value ="warn" />
</logger>
<root>
<priority value ="info" />
<appender-ref ref="fileAppender" />
<appender-ref ref="STDOUT" />
</root>
</log4j:configuration>
** EDIT - 2/19/14 1226 **
Here's the actual .batch file that is calling everything;
SET DLPATH="M:\My Folder\XXXXXXXXXXXXXXXXX\CSV Files\salesforce.com\Apex Data Loader 22.0"
SET DLCONF="M:\My Folder\XXXXXXXXXXXXXXXXX\CSV Files\salesforce.com\Apex Data Loader 22.0\cliq_process\Update_Listing_Val_FNMA\config"
SET DLDATA="M:\My Folder\XXXXXXXXXXXXXXXXX\CSV Files\salesforce.com\Apex Data Loader 22.0\cliq_process\Update_Listing_Val_FNMA\write"
call %DLPATH%\_jvm\bin\java.exe -cp %DLPATH%\DataLoader.jar -Dsalesforce.config.dir=%DLCONF% com.salesforce.dataloader.process.ProcessRunner process.name=Update_Listing_Val_FNMA
REM To rotate your export files, uncomment the line below
REM copy %DLDATA%\Update_Listing_Val_FNMA.csv %DLDATA%\%date:~10,4%%date:~7,2%%date:~4,2%-%time:~0,2%-Update_Listing_Val_FNMA.csv

SQL Server xml.modify delete method

I have a problem with removing an attribute from a node.
Example:
DECLARE #processID int
SET #processID = 8
DECLARE #xml XML
SET #xml =
'<Process id="10" name="Test 1">
<Shapes>
<Shape id="1" name="Shape 1" subProcessID="8">
</Shape>
<Shape id="2" name="Shape 2" subProcessID="9">
</Shape>
</Shapes>
<Lines />
</Process>'
SET #xml.modify('delete (/Process/Shapes/Shape/#subProcessID[/Process/Shapes/Shape/#subProcessID = sql:variable("#processID")])')
SELECT #xml
Gives the result:
<Process id="10" name="Test 1">
<Shapes>
<Shape id="1" name="Shape 1" />
<Shape id="2" name="Shape 2" />
</Shapes>
<Lines />
</Process>
What I would like is:
<Process id="10" name="Test 1">
<Shapes>
<Shape id="1" name="Shape 1" />
<Shape id="2" name="Shape 2" subProcessID="9" />
</Shapes>
<Lines />
</Process>
What is the syntax to achieve this?
As the OP is gone but he left the solution in a comment let me add that as an answer:
DECLARE #processID int
SET #processID = 8
DECLARE #xml XML
SET #xml =
'<Process id="10" name="Test 1">
<Shapes>
<Shape id="1" name="Shape 1" subProcessID="8">
</Shape>
<Shape id="2" name="Shape 2" subProcessID="9">
</Shape>
</Shapes>
<Lines />
</Process>'
SET #xml.modify('delete (/Process/Shapes/Shape[#subProcessID = sql:variable("#processID")]/#subProcessID)')
SELECT #xml
Here is a working sqlfiddle for that.

Resources