xslt - Nothing returned for element name (XSL/XPath) -


I have a code that expects me to return the element name, but nothing is returned.

The following code is from an XSL doctor which creates another XSL doctor. Where $ expression is a variable that has created an XPath expression dynamically.

  & lt; Xsl: template match = "/" & gt; ... & lt; Xslt: template match = "{$ expression}" & gt; & Lt; Elem key = "{name ()}" & gt; & Lt; Xslt: copy-of select = "@ *" / & gt; & Lt; Xslt: each selection = "@ *" & gt; & Lt; Xslt: sort select = "name ()" /> & Lt; Specialty & gt; | & Lt; Xslt: Select the value = "name ()" /> | & Lt; / Attribute & gt; & Lt; / Xslt: for-each & gt; & Lt; / ELEM & gt; & Lt; / Xslt: Templates & gt; ... & lt; / Xsl: Templates & gt;   

The second XSL doctor is generated with this code after that code. Note how @key is empty.

  & lt; Xsl: template match = "/ / * [[@ name = 'spot']" & gt; & Lt; Elem key = "" & gt; & Lt; Xsl: copy-of select = "@ *" / & gt; & Lt; Xsl: each selection = "@ *" & gt; & Lt; Xsl: Select Sort = "Name ()" /> & Lt; Specialty & gt; | & Lt; Xsl: Select the value = "name ()" /> | & Lt; / Attribute & gt; & Lt; / XSL: for-each & gt; & Lt; / ELEM & gt; & Lt; / XSL: Templates & gt;  

In addition to @key empty, everything works as expected. My only problem is displaying the name of the element.

EDIT: To clarify what I'm actually looking into, let me do & lt; Xslt: template match = "{$ expression}" & gt; .

Thank you! :)

Because your change is producing XSLT code itself and you want to be in the result:

  & lt; Elem key = "{name ()}" & gt;  

You have to protect from { and } so that AVT can not be immediately evaluated.

{ and } is created by repeating them as :

"When a feature value template is instant, a double left or right curly brace will be replaced by a single pedestal brace outside the expression."

Therefore, replace :

  & lt; Xslt: template match = "{$ expression}" & gt; & Lt; Elem key = "{name ()}" & gt; & Lt; Xslt: copy-of select = "@ *" / & gt; & Lt; Xslt: each selection = "@ *" & gt; & Lt; Xslt: sort select = "name ()" /> & Lt; Specialty & gt; | & Lt; Xslt: Select the value = "name ()" /> | & Lt; / Attribute & gt; & Lt; / Xslt: for-each & gt; & Lt; / ELEM & gt; & Lt; / Xslt: Templates & gt;  

with:

  & lt; Xslt: template match = "{$ expression}" & gt; & Lt; Elem key = "{{name ()}}" & gt; & Lt; Xslt: copy-of select = "@ *" / & gt; & Lt; Xslt: each selection = "@ *" & gt; & Lt; Xslt: sort select = "name ()" /> & Lt; Specialty & gt; | & Lt; Xslt: Select the value = "name ()" /> | & Lt; / Attribute & gt; & Lt; / Xslt: for-each & gt; & Lt; / ELEM & gt; & Lt; / Xslt: Templates & gt;  

As a result, you will get:

  & lt; Xsl: template match = "// * [[@ name = 'spot']" & gt; & Lt; Elem key = "{name ()}" & gt; & Lt; Xsl: copy-of select = "@ *" / & gt; & Lt; Xsl: each selection = "@ *" & gt; & Lt; Xsl: Select Sort = "Name ()" /> & Lt; Specialty & gt; | & Lt; Xsl: Select the value = "name ()" /> | & Lt; / Attribute & gt; & Lt; / XSL: for-each & gt; & Lt; / ELEM & gt; & Lt; / XSL: Templates & gt;  

Note : I'm surprised that this code works at all. You can see & lt; Xsl: namespace-alias & gt; should use the XSLT command.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -