Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I created an XSLT translation for XML that looks like this that was workign as expected:

<?xml version="1.0" encoding="utf-8"?>
<bsar:BSAForm xmlns:bsar="http://www.fincen.gov/bsa/bsar/2011-06-01">
    <bsar:FilingInstitutionInformation>
        <bsar:PrimaryRegulator>D</bsar:PrimaryRegulator>
        ...
    </bsar:FilingInstitutionInformation>
    ...
</bsar:BSAForm>

The translation looks like this:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="text" />
      <xsl:template match="bsar:BSAForm">

        <!--Output Filing Institution Information Record-->
        <xsl:call-template name="FileInstActivity"/>

        ...

      </xsl:template>

      <xsl:template name="FileInstActivity">
           <xsl:value-of select="bsar:PrimaryRegulator"/>
           ...
      </xsl:template>
</xsl:stylesheet>

This works as expected and shows the following output:

D

Now, I am finding that my input XML will looks like the following instead, but I'm having some trouble adjusting the xpath accordingly:

<?xml version="1.0" encoding="utf-8"?>
<form version="2.0">
<meta>
    <field name="ID">54</field>
    <field name="Title">SAR 2012 #1</field>
    <field name="Assigned_x0020_To">MEMENTO-INC\memento_admin</field>
    <field name="Status">1; Open</field>
    <field name="Form_x0020_Type">9; SAR 2012</field>
    <field name="Alert">1</field>
    <field name="Due_x0020_Date">9999-12-31T23:59:59</field>
    <field name="Is_x0020_Complete">False</field>
    <field name="ValidationMessages">Memento.Forms.Core.Messages</field>
    <field name="Closed" />
    <field name="ClosedBy" />
    <field name="editMaster" />
    <field name="dateOfInitialDetection">9999-12-31T23:59:59</field>
    <field name="dataBlobXml">
        &lt;bsar:BSAForm xmlns:bsar="http://www.fincen.gov/bsa/bsar/2011-06-01"&gt;
        &lt;bsar:FilingInstitutionInformation&gt;
        &lt;bsar:PrimaryRegulator>D&gt;%lt;/&gt;
        ...
    </field>
</meta>
</form>

No matter how I edit the xpath of my template (bsar:BSAForm), it seems to keep showing all the text from the other field sections, as well as the rest of the XML (I'm working on the issue with the & lt; and & gt; but that's another issue):

54SAR 2012 #1MEMENTO-INC\memento_admin1; Open9; SAR 201219999-12-31T23:59:59FalseMemento.Forms.Core.Messages9999-12-31T23:59:59
        <bsar:BSAForm xmlns:bsar="http://www.fincen.gov/bsa/bsar/2011-06-01">

Thanks in advance

share|improve this question

closed as off topic by John Chapman, Andrey Markeev, PirateEric, RJ Cuthbertson, ali Sharepoint Mar 9 '13 at 16:23

Questions on SharePoint Stack Exchange are expected to relate to SharePoint within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

    
What have you tried, and what do you want the output to look like? The second XML schema is substantially different from the first, and it's not clear what you expect. –  wst Feb 28 '13 at 19:10
1  
I honestly don't see how your question relates to SharePoint. –  Andrey Markeev Feb 28 '13 at 19:21
    
The XML is coming from a Sharepoint list item –  Music Magi Feb 28 '13 at 19:33
    
In my post it is noted what is expected: This works as expected and shows the following output: D –  Music Magi Feb 28 '13 at 19:35
add comment

1 Answer 1

You can reach the text inside dataBlobXml using the following template:

<xsl:template match="field[@name='dataBlobXml']">
   <xsl:value-of select="." />
</xsl:template>

But this will come as text node into the template. So if you want to parse it further, you will have to either use string functions (like substring-before and substring-after) or perform second XSLT transformation (i.e. pass results of the first transformation to the second one).

First approach can be implemented using the following code:

<xsl:template match="field[@name='dataBlobXml']">
   <xsl:value-of select="substring-before(substring-after(.,'&lt;bsar:PrimaryRegulator&gt;'),'&lt;/')"/>
</xsl:template>

(not tested, but hopefully you've got the idea)

P.S. Based on my understanding this question doesn't relate to SharePoint directly and I myself voted to close it as offtopic, but since in SharePoint we frequently have to deal with XSLT, I think this answer might be useful for the site members anyway.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.