Skip to content

Instantly share code, notes, and snippets.

@edegula
edegula / fieldsToNull.xsl
Created April 29, 2015 03:40
XSLT Template - fieldsToNull for Salesforce; Enumerate the list of blank nodes into a target node
<!-- The template matching sObjects/sObject/*[not(node())], when selected for execution, does nothing, which results in
"deleting" (not copying) the matched node in the output.-->
<xsl:template match="sObjects/sObject/*[not(node())]"/>
<!--The template below matching fieldsToNull has a higher priority specified than the "deleting" template above,
so it is selected for execution on any fieldsToNull element.
The matched fieldsToNull element is shallow-copied to the output,
and then its content (body) is produced by applying templates in mode enumerate to all empty siblings-elements.
-->
<xsl:template match="fieldsToNull" priority="5">
@edegula
edegula / xlst_template_copy_all
Created April 29, 2015 03:30
XSLT Template - Copy the entire document
<!--This identity rule when selected for execution matches all attributes (@*) and elements (node()) in the source xml
It results in a copy the entire document 'as-is' -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
@edegula
edegula / salesforce_create_taskrelation
Created March 26, 2015 06:22
Create a TaskRelation Object using Salesforce Enterprise WSDL
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com" xmlns:si="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<urn:SessionHeader>
<urn:sessionId>NNNNNNN</urn:sessionId>
</urn:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<urn:create>
<urn:sObjects si:type="TaskRelation">
<!--Zero or more repetitions:-->
@edegula
edegula / List of Stan Countries
Created March 19, 2015 02:14
XSLT Exercise - Find all country names containing the string "stan"; return each one within a "Stan" element.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="country">
<xsl:if test="contains(@name, 'stan')">
<xsl:element name="Stan">
<xsl:value-of select="@name" />
</xsl:element>
</xsl:if>
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match=" node() | @* ">
<xsl:copy>
<xsl:apply-templates select="node() | @*" />
</xsl:copy>
</xsl:template>
<xsl:template match="Department/Course[@Enrollment &gt; 60]" />
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="text()" />
<xsl:template match="Department[@Code = 'EE']/Course">
<xsl:copy>
<xsl:copy-of select="@*"/>
@edegula
edegula / search_text_manually.js
Created June 25, 2013 15:56
Manually searching for texts in JS
var text = "thisis is sisi sis iskallakksdj lakdjf asdf hark \
the cannons hear them Elias alksdfjalksdjkjaskdjflk kajsdfkj \
Erwin kajsdklfjasdfjlkj asdf Erwin sakaksl askdfjaskdfj Erwin",
myName = "Erwin",
hits = [];
for ( var i = 0; i < text.length; i++ ) {
if ( text[i] === myName[0] ) {
var count = 0;
var index = hits.length - 1;
@edegula
edegula / ABAP_Dynamic_Struct.abap
Created June 12, 2013 07:07
A sample method for create a structure and internal table dynamically using RTTC of RTTI.
*----------------------------------------------------------------
* METHOD create_tab_for_display
* IMPORTING
* edo_table type ref to data
* edo_struc type ref to data.
*----------------------------------------------------------------
method create_tab_for_display.
data:
go_sdescr_new type ref to cl_abap_structdescr,
@edegula
edegula / Challenge001e.java
Created May 7, 2013 10:10
/r/dailyprogrammer #001 - Easy
package com.edegula.reddit.dailyprog.easy;
import java.util.Scanner;
public class Challenge001 {
private Scanner scanner;
private String name;
private int age;
private String userName;
report helloworld.
write 'hello world'.