Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi all !
someone know how to update some value node in a document type using xslt ??
Hi Andres,
You can do it by using c# coding and umbraco api within the xslt block. Here is an example about using c# and umbraco api within xslt
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:visitTrack="urn:visitTrack" xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets "><xsl:output method="xml" omit-xml-declaration="yes"/><xsl:param name="currentPage"/><xsl:template match="/"><!-- start writing XSLT --><xsl:variable name="pageId" select="$currentPage/@id"/><xsl:value-of select="visitTrack:updateVisit($pageId)"/></xsl:template><msxml:script language="C#" implements-prefix="visitTrack"> <msxml:assembly href="../bin/cms.dll" /> <msxml:assembly href="../bin/umbraco.dll" /> <msxml:assembly href="../bin/businesslogic.dll" /> <msxml:using namespace="umbraco.BusinessLogic" /> <msxml:using namespace="umbraco.cms.businesslogic.web" /> <msxml:using namespace="umbraco.cms.businesslogic.web" /> public static string updateVisit(int pageId) { User author = User.GetUser(0); Document doc = new Document(pageId); int getCount=int.Parse(doc.getProperty("visit").Value.ToString()) + 1; doc.getProperty("visit").Value = getCount.ToString(); doc.Publish(author); umbraco.library.UpdateDocumentCache(doc.Id); return getCount.ToString(); } </msxml:script></xsl:stylesheet>
Hope this helps you
Pnima
thanks ! I'm using it !
I'm tying to apply for a quiz example but I couldn't fix this errorr....
System.Xml.Xsl.XslLoadException: Prefix 'visitTrack' is not defined. An error occurred at
I change visitTrack but what king of value or function can use ?
Changed all the "visitTrack" word? If you change the prefix from
<msxml:script language="C#" implements-prefix="visitTrack">
then you have to change in
xmlns:visitTrack="urn:visitTrack"
<xsl:value-of select="visitTrack:updateVisit($pageId)"/>
Hope this helps
look at this error too :
System.NullReferenceException: Object reference not set to an instance of an object.
Please look my code to fix...
If you have another answer or option to dev this code please let me know...
<xsl:param name="currentPage"/>
<xsl:template match="/">
<!-- start writing XSLT -->
<script type="text/javascript">
iSend = $("#content input[name=quiz]:checked").val();
</script>
<xsl:variable name="tmp">
<xsl:value-of select="isend"/>
</xsl:variable>
<xsl:variable name="myvar" select="number($tmp)"/>
<xsl:value-of select="visitTrack:updateVisit($myvar)"/>
</xsl:template>
<msxml:assembly href="../bin/cms.dll" />
<msxml:assembly href="../bin/umbraco.dll" />
<msxml:assembly href="../bin/businesslogic.dll" />
<msxml:using namespace="umbraco.BusinessLogic" />
<msxml:using namespace="umbraco.cms.businesslogic.web" />
public static string updateVisit(int myvar)
{
User author = User.GetUser(0);
Document doc = new Document(myvar);
int getCount=int.Parse(doc.getProperty("visit").Value.ToString()) + 1;
doc.getProperty("visit").Value = getCount.ToString();
doc.Publish(author);
umbraco.library.UpdateDocumentCache(doc.Id);
return getCount.ToString();
}
</msxml:script>
</xsl:stylesheet>
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
updating nodes from xslt ?
Hi all !
someone know how to update some value node in a document type using xslt ??
Hi Andres,
You can do it by using c# coding and umbraco api within the xslt block. Here is an example about using c# and umbraco api within xslt
Hope this helps you
Pnima
thanks ! I'm using it !
I'm tying to apply for a quiz example but I couldn't fix this errorr....
System.Xml.Xsl.XslLoadException: Prefix 'visitTrack' is not defined. An error occurred at
I change visitTrack but what king of value or function can use ?
Changed all the "visitTrack" word? If you change the prefix from
then you have to change in
Hope this helps
look at this error too :
System.NullReferenceException: Object reference not set to an instance of an object.
Please look my code to fix...
If you have another answer or option to dev this code please let me know...
<xsl:param name="currentPage"/>
<xsl:template match="/">
<!-- start writing XSLT -->
<script type="text/javascript">
iSend = $("#content input[name=quiz]:checked").val();
</script>
<xsl:variable name="tmp">
<xsl:value-of select="isend"/>
</xsl:variable>
<xsl:variable name="myvar" select="number($tmp)"/>
<xsl:value-of select="visitTrack:updateVisit($myvar)"/>
</xsl:template>
<msxml:script language="C#" implements-prefix="visitTrack">
<msxml:assembly href="../bin/cms.dll" />
<msxml:assembly href="../bin/umbraco.dll" />
<msxml:assembly href="../bin/businesslogic.dll" />
<msxml:using namespace="umbraco.BusinessLogic" />
<msxml:using namespace="umbraco.cms.businesslogic.web" />
<msxml:using namespace="umbraco.cms.businesslogic.web" />
public static string updateVisit(int myvar)
{
User author = User.GetUser(0);
Document doc = new Document(myvar);
int getCount=int.Parse(doc.getProperty("visit").Value.ToString()) + 1;
doc.getProperty("visit").Value = getCount.ToString();
doc.Publish(author);
umbraco.library.UpdateDocumentCache(doc.Id);
return getCount.ToString();
}
</msxml:script>
</xsl:stylesheet>
is working on a reply...