Who have written the "DesignetExter" extension? It's probably in the underlying C# code there that something needs to be changed in order to have the proper XML output.
Ok, at a first glance that looks fine to me. But I'm not a backed developer so I might be missing something.
However I just glanced through the posts again and saw that you also have a $csvVartypes variable. Could you please post the whole source code of the XSLT file so we get the full context?
It generates string like 'Stationcar,Cabriolet,SUV' and this value is being sent to the extension and the resulted string is like what I have posted earlier.
XSLT is probably not the ideal language to be using for stuff like this...however it should work from what I can tell so I'm a bit puzzled as to why you get those strings.
Is the XSLT file saved using UTF-8 encoding? You should not need to escape the output when it's used like you're doing above. It's usually when you want to render content from for instance a rich text editor property that you need it.
I am Backend developer. I needed to generate a full combinatoin of given list of car types and doing this in XSLT is a big mess. So I created this extension. the input text is : "Stationcar,Cabriolet,SUV" and the output text is "Stationcar, Cabriolet, SUV, Stationcar Cabriolet, Stationcar SUV, Cabriolet SUV, Stationcar Cabriolet SUV"
In order to manage it in XSLT the only way comes to my mind was convert it to an XML format.
Do you know how can I split a comma separated value (Stationcar,Cabriolet,SUV" and the output text is "Stationcar, Cabriolet, SUV, Stationcar Cabriolet, Stationcar SUV, Cabriolet SUV, Stationcar Cabriolet SUV) to be used in a xslt for-each loop?
Of course making an XSLT extension is a good thing. No doubt about that but some of the values you need and the way you need to loop through them are a bit messy. Not saying it can be done and the approach with your extension is indeed good :)
Umbraco delivers some XSLT extensions and one of them is Split, that is used for splitting up comma-seperated content. It can be used like <xsl:variable name="cars" select="umbraco.library:Split(nameofyourumbracoproperty,',')" /> - The first parameter is your property alias and the second parameter is the character you want to split it by. In your case "comma".
To use a result tree fragment in a path expression, first convert it to a node-set using the msxsl:node-set() function
I have following XSLT code:
.......
Value for HtmlPermulations is as follow:
But when I am trying to use it in this for-each loop:
I am getting this error message:
Can anyone help?
Hi Amir
If you ditch the test-variable and write this instead, what happens then?
<xsl:for-each select="msxsl:node-set($HtmlPermulations/root/item)">
<xsl:value-of select="." />
</xsl:for-each>
/Jan
I do not have msxsl, so Do you mean:
<xsl:for-each select="msxml:node-set($HtmlPermulations/root/item)">
<xsl:value-of select="." />
</xsl:for-each>
?
if so, I am getting this error:
Expression must evaluate to a node-set.
Hi Amir
Argh, I made a mistake in my example above. the /root/item part should be after the closing paranthesis. So write it like this instead
<xsl:for-each select="msxml:node-set($HtmlPermulations)/root/item">
<xsl:value-of select="." />
</xsl:for-each>
Does it work now?
/Jan
It does not go through the loop.
I think its because of the HTML format as its having
<
and
>
Am I right?
Hi Amir
Well to me it looks like XML that is returned but yes that is probably the reason. Why is it returned like that? (Missed it in the other post).
/Jan
This string is being generated in a class extention as below:
How can I disable-output-escaping for this?
I tried it using test:
but still test is holding invalid characters.
Any suggestions?
Hi Amir
Who have written the "DesignetExter" extension? It's probably in the underlying C# code there that something needs to be changed in order to have the proper XML output.
/Jan
Hi Jan,
I have developed it my self and here is the code:
Any clue?
Hi Amir
Ok, at a first glance that looks fine to me. But I'm not a backed developer so I might be missing something.
However I just glanced through the posts again and saw that you also have a $csvVartypes variable. Could you please post the whole source code of the XSLT file so we get the full context?
Thanks,
Jan
Hi Jan,
csvCarTypes is as below:
It generates string like 'Stationcar,Cabriolet,SUV' and this value is being sent to the extension and the resulted string is like what I have posted earlier.
Hi Amir
Ok, thanks.
XSLT is probably not the ideal language to be using for stuff like this...however it should work from what I can tell so I'm a bit puzzled as to why you get those strings.
Is the XSLT file saved using UTF-8 encoding? You should not need to escape the output when it's used like you're doing above. It's usually when you want to render content from for instance a rich text editor property that you need it.
/Jan
I am Backend developer. I needed to generate a full combinatoin of given list of car types and doing this in XSLT is a big mess. So I created this extension. the input text is : "Stationcar,Cabriolet,SUV" and the output text is "Stationcar, Cabriolet, SUV, Stationcar Cabriolet, Stationcar SUV, Cabriolet SUV, Stationcar Cabriolet SUV"
In order to manage it in XSLT the only way comes to my mind was convert it to an XML format.
Do you have any better idea?
Jan,
Do you know how can I split a comma separated value (Stationcar,Cabriolet,SUV" and the output text is "Stationcar, Cabriolet, SUV, Stationcar Cabriolet, Stationcar SUV, Cabriolet SUV, Stationcar Cabriolet SUV) to be used in a xslt for-each loop?
Hi Amir
Of course making an XSLT extension is a good thing. No doubt about that but some of the values you need and the way you need to loop through them are a bit messy. Not saying it can be done and the approach with your extension is indeed good :)
Umbraco delivers some XSLT extensions and one of them is Split, that is used for splitting up comma-seperated content. It can be used like <xsl:variable name="cars" select="umbraco.library:Split(nameofyourumbracoproperty,',')" /> - The first parameter is your property alias and the second parameter is the character you want to split it by. In your case "comma".
By writing
<textarea>
<xsl:copy-of select="$cars" />
</textarea>
You should see some XML output like this
<values>
<value>Value 1</value>
<value>Value 2</value>
</values>
Is this what you're after?
Cheers,
Jan
Thans Jan,
Its kindo solved my problem.
But still its I am getting some strange HTML variables
My Xslt is now like :
and the output html is:
From Here <div class="Stationcar
										" /><div class="Cabriolet
										" /><div class="SUV" /><div class="Stationcar
										 Cabriolet" /><div class="Stationcar
										 SUV" /><div class="Cabriolet
										 SUV" /><div class="Stationcar
										 Cabriolet
										 SUV" /> To Here
I am not sure where exactlt these html codes are coming from
While If I dont use the loop for populating classes and put the value directly inside the a div, the output Html would be like this:
Have any idea whats going on here?
Could you please show me the output of the $types varaible?
Just write it out in a textarea exactly like below - no use of xml:space or any other attributes.
<textarea>
<xsl:copy-of select="$types" />
</textarea>
/Jan
Hi Jan,
Thanks and sorry for the late reply.
The requested output is as below:
<textarea><values><value>Stationcar </value><value>Cabriolet </value><value>SUV</value><value>Stationcar Cabriolet</value><value>Stationcar SUV</value><value>Cabriolet SUV</value><value>Stationcar Cabriolet SUV</value></values></textarea>
It looks fine, but when I try following code:
<xsl:for-each select="msxml:node-set($normalizedTypes)/values/*">
<div>
<xsl:attribute name="class">
<xsl:value-of select="."/>
</xsl:attribute>
</div>
</xsl:for-each>
the output is as follow which is a bit messy!
<div class="Stationcar
										" /><div class="Cabriolet
										" /><div class="SUV" /><div class="Stationcar
										 Cabriolet" /><div class="Stationcar
										 SUV" /><div class="Cabriolet
										 SUV" /><div class="Stationcar
										 Cabriolet
										 SUV" />
Hi Amir
Ok, are you somewhere in your code using either xsl:strip-space or xsl:preserve-space?
Otherwise try writing you value-of like this <xsl:value-of select="normalize-space(.)" />
Hope this helps.
/Jan
Yessssssss,
normalize-space(.) works. Awsome Jan. Thanks alot.
Hi Amir
Glad to hear it finally worked out :)
/Jan
is working on a reply...