Click here to Skip to main content
15,886,798 members
Home / Discussions / XML / XSL
   

XML / XSL

 
GeneralRe: saving a file to the internet. Pin
Richard MacCutchan1-Jun-17 1:03
mveRichard MacCutchan1-Jun-17 1:03 
GeneralRe: saving a file to the internet. Pin
Gerry Schmitz1-Jun-17 3:20
mveGerry Schmitz1-Jun-17 3:20 
AnswerRe: saving a file to the internet. Pin
Terry Perez11-Sep-17 3:41
Terry Perez11-Sep-17 3:41 
QuestionXSLT passing a variable to starts-with Pin
bjmallon13-Feb-17 14:03
bjmallon13-Feb-17 14:03 
AnswerRe: XSLT passing a variable to starts-with Pin
Richard Deeming14-Feb-17 2:32
mveRichard Deeming14-Feb-17 2:32 
GeneralRe: XSLT passing a variable to starts-with Pin
bjmallon16-Feb-17 18:45
bjmallon16-Feb-17 18:45 
GeneralRe: XSLT passing a variable to starts-with Pin
Richard Deeming17-Feb-17 1:48
mveRichard Deeming17-Feb-17 1:48 
GeneralRe: XSLT passing a variable to starts-with Pin
bjmallon20-Feb-17 22:55
bjmallon20-Feb-17 22:55 
Richard,

Sorry I haven't replied earlier. I went on leave the day you responded and have been... occupied since.

I tried your suggestion, without success, although it has given me something to pursue.

As requested, the tokenisation templates I gleaned from other forum sources a fair while ago are below. It worked well for what I was doing then, but it may not be the best for what I'm attempting now.

Any advice would be appreciated.

XML
<!-- Tokenisation templates -->
  <xsl:template name="tokenise">
    <xsl:param name="string" select="''" />
    <xsl:param name="delimiters" select="' 	'" />
    <xsl:choose>
      <!-- Nothing to do if empty string -->
      <xsl:when test="not($string)" />

      <!-- No delimiters signals character level tokenization. -->
      <xsl:when test="not($delimiters)">
        <xsl:call-template name="_tokenise-characters">
          <xsl:with-param name="string" select="$string" />
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="_tokenise-delimiters">
          <xsl:with-param name="string" select="$string" />
          <xsl:with-param name="delimiters" select="$delimiters" />
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="_tokenise-characters">
    <xsl:param name="string" />
    <xsl:if test="$string">
      <token>
        <xsl:value-of select="substring($string, 1, 1)" />
      </token>
      <xsl:call-template name="_tokenise-characters">
        <xsl:with-param name="string" select="substring($string, 2)" />
      </xsl:call-template>
    </xsl:if>
  </xsl:template>

  <xsl:template name="_tokenise-delimiters">
    <xsl:param name="string" />
    <xsl:param name="delimiters" />
    <xsl:param name="last-delimit"/>
    <!-- Extract a delimiter -->
    <xsl:variable name="delimiter" select="substring($delimiters, 1, 1)" />
    <xsl:choose>
      <!-- If the delimiter is empty we have a token -->
      <xsl:when test="not($delimiter)">
        <token>
          <xsl:value-of select="$string"/>
        </token>
      </xsl:when>
      <!-- If the string contains at least one delimiter we must split it -->
      <xsl:when test="contains($string, $delimiter)">
        <!-- If it starts with the delimiter we don't need to handle the -->
        <!-- before part -->
        <xsl:if test="not(starts-with($string, $delimiter))">
          <!-- Handle the part that comes befor the current delimiter -->
          <!-- with the next delimiter. If ther is no next the first test -->
          <!-- in this template will detect the token -->
          <xsl:call-template name="_tokenise-delimiters">
            <xsl:with-param name="string"
                            select="substring-before($string, $delimiter)" />
            <xsl:with-param name="delimiters"
                            select="substring($delimiters, 2)" />
          </xsl:call-template>
        </xsl:if>
        <!-- Handle the part that comes after the delimiter using the -->
        <!-- current delimiter -->
        <xsl:call-template name="_tokenise-delimiters">
          <xsl:with-param name="string"
                          select="substring-after($string, $delimiter)" />
          <xsl:with-param name="delimiters" select="$delimiters" />
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <!-- No occurances of current delimiter so move on to next -->
        <xsl:call-template name="_tokenise-delimiters">
          <xsl:with-param name="string"
                          select="$string" />
          <xsl:with-param name="delimiters"
                          select="substring($delimiters, 2)" />
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>

GeneralRe: XSLT passing a variable to starts-with Pin
Richard Deeming21-Feb-17 1:42
mveRichard Deeming21-Feb-17 1:42 
GeneralRe: XSLT passing a variable to starts-with Pin
bjmallon21-Feb-17 10:24
bjmallon21-Feb-17 10:24 
QuestionHow to generate XML file with serialisation in vb.net Pin
Member 1280320219-Oct-16 8:06
Member 1280320219-Oct-16 8:06 
Rant[REPOST] How to generate XML file with serialisation in vb.net Pin
Richard Deeming19-Oct-16 9:28
mveRichard Deeming19-Oct-16 9:28 
QuestionTransform the date format from yyyy/mm/dd to mm/dd/yyyy Pin
Member 1278840611-Oct-16 15:21
Member 1278840611-Oct-16 15:21 
AnswerRe: Transform the date format from yyyy/mm/dd to mm/dd/yyyy Pin
Richard Deeming12-Oct-16 3:26
mveRichard Deeming12-Oct-16 3:26 
QuestionRead xml string Pin
trungysp198610-Oct-16 14:48
trungysp198610-Oct-16 14:48 
AnswerRe: Read xml string Pin
Richard MacCutchan10-Oct-16 21:54
mveRichard MacCutchan10-Oct-16 21:54 
AnswerRe: Read xml string Pin
Swinkaran11-Oct-16 16:09
professionalSwinkaran11-Oct-16 16:09 
QuestionXML Pin
Member 1273144310-Sep-16 3:41
Member 1273144310-Sep-16 3:41 
AnswerRe: XML Pin
OriginalGriff10-Sep-16 3:44
mveOriginalGriff10-Sep-16 3:44 
GeneralRe: XML Pin
Member 1273144310-Sep-16 3:48
Member 1273144310-Sep-16 3:48 
GeneralRe: XML Pin
Member 1273144310-Sep-16 3:52
Member 1273144310-Sep-16 3:52 
GeneralRe: XML Pin
OriginalGriff10-Sep-16 4:06
mveOriginalGriff10-Sep-16 4:06 
GeneralRe: XML Pin
Member 1273144310-Sep-16 4:18
Member 1273144310-Sep-16 4:18 
GeneralRe: XML Pin
OriginalGriff10-Sep-16 4:27
mveOriginalGriff10-Sep-16 4:27 
GeneralRe: XML Pin
Member 1273144310-Sep-16 4:38
Member 1273144310-Sep-16 4:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.