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,
my xml of macro container is:
<slideShow>
<?UMBRACO_MACRO macroalias="SlideShowHomeItem" linkArticolo="1078" imgAlternativa="" titleAlternativo="" />
<?UMBRACO_MACRO macroalias="SlideShowHomeItem" linkArticolo="1079" imgAlternativa="" titleAlternativo="" />
</slideShow>
My requirement is to read through a xslt/for-each properties of each macro in the macro container.
How can I do? Thanks to everyone for availability.
To be clearer, I have a macro container and a new macro I have to read through the items in the container macro.
I'm looking at every way to read items through the new macro with a foreach loop, but without success.
The XML above is generated by the macro container.
I hope you understand. Thanks in advance for the answer
I solved with XSLT extensions:
///<summary>
/// XSLT extensions, referenced from /config/xsltExtensions.config:
/// <ext assembly="/bin/MyAssembly" type="MyTypeName" alias="MyExtensions"/>
///</summary>
public class MyExtensions
{
private static Regex MacroExpression = new Regex("<?umbraco_macro (.*?)/>",
RegexOptions.Singleline | RegexOptions.IgnoreCase);
private static Regex PropertyExpression = new Regex("(\\S*?)=\"(.*?)\"",
public XPathNodeIterator DecodeMacroReferences(string input)
var doc = new XDocument();
var macros = new XElement("macros");
doc.Add(macros);
foreach (Match match in MacroExpression.Matches(input))
var macro = new XElement("macro");
foreach (Match propMatch in PropertyExpression.Matches(match.Groups[1].Value))
macro.Add(new XAttribute(propMatch.Groups[1].Value, propMatch.Groups[2].Value));
}
macros.Add(macro);
return doc.CreateNavigator().Select("/");
found at: http://www.rightpoint.com/community/blogs/viewpoint/archive/2010/09/29/treating-umbraco-macro-references-as-data.aspx
that has transformed the xml generated by the macro container:
<macros>
<macro macroalias="SlideShowHomeItem" linkArticolo="1078" imgAlternativa="" titleAlternativo="" />
<macro macroalias="SlideShowHomeItem" linkArticolo="1079" imgAlternativa="" titleAlternativo="" />
</macros>
Now I can access the properties of each element with a simple loop:
<xsl:variable name="macroSlideShow" select="$currentPage/slideShow" /><!--Alias Macro Container in Document Types-->
<xsl:for-each select="msxml:node-set(Ext.ItemMacroContainer:DecodeMacroReferences($macroSlideShow))/macros/child::*"> <xsl:variable name="currentNode" select="."/> <textarea> <xsl:value-of select="$currentNode/@linkArticolo"/> </textarea> </xsl:for-each>
Happy to have solved, I was about to leave.
Umbraco v 4.7.1.1
If there is a better solution let me know :-)
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Help Parse Macro Parameters from Macro Container
Hi,
my xml of macro container is:
<slideShow>
<?UMBRACO_MACRO macroalias="SlideShowHomeItem" linkArticolo="1078" imgAlternativa="" titleAlternativo="" />
<?UMBRACO_MACRO macroalias="SlideShowHomeItem" linkArticolo="1079" imgAlternativa="" titleAlternativo="" />
</slideShow>
My requirement is to read through a xslt/for-each properties of each macro in the macro container.
How can I do? Thanks to everyone for availability.
To be clearer, I have a macro container and a new macro I have to read through the items in the container macro.
I'm looking at every way to read items through the new macro with a foreach loop, but without success.
The XML above is generated by the macro container.
I hope you understand. Thanks in advance for the answer
I solved with XSLT extensions:
macro.Add(new XAttribute(propMatch.Groups[1].Value, propMatch.Groups[2].Value));
found at: http://www.rightpoint.com/community/blogs/viewpoint/archive/2010/09/29/treating-umbraco-macro-references-as-data.aspx
that has transformed the xml generated by the macro container:
<macros>
<macro macroalias="SlideShowHomeItem" linkArticolo="1078" imgAlternativa="" titleAlternativo="" />
<macro macroalias="SlideShowHomeItem" linkArticolo="1079" imgAlternativa="" titleAlternativo="" />
</macros>
Now I can access the properties of each element with a simple loop:
<xsl:variable name="macroSlideShow" select="$currentPage/slideShow" /><!--Alias Macro Container in Document Types-->
<xsl:for-each select="msxml:node-set(Ext.ItemMacroContainer:DecodeMacroReferences($macroSlideShow))/macros/child::*">
<xsl:variable name="currentNode" select="."/>
<textarea>
<xsl:value-of select="$currentNode/@linkArticolo"/>
</textarea>
</xsl:for-each>
Happy to have solved, I was about to leave.
Umbraco v 4.7.1.1
If there is a better solution let me know :-)
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.