Include a XML in XSLT and then apply a foreach -


I have a website with XML + XSLT which shows me a complete HTML website Now, to make the site more dynamic For, I want to divide the parts of the document: I was looking at Google headers, footers and sidebar and I found this solution:

   & Lt; Xsl: template match = "/" & gt; & Lt; Html & gt; & Lt; Head & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Xsl: each selection = "$ doc" & gt; & Lt; Xsl: apply-template / & gt; & Lt; / Xsl: each -G & gt; & Lt; / Body & gt; & Lt; / Html & gt; & Lt; / XSL: Templates & gt;  

I was trying to implement it and I can work on it. This is the way I am using:

I have changed the path to "../menu.xml", because XLL is inside a folder, it works well.

  & lt ;? XML version = "1.0" encoding = "ISO-8859-1"? & Gt; & Lt; Xsl: stylesheet version = "1.0" xmlns: xsl = "http://www.w3.org/1999/XSL/transform" & gt; & Lt; Xsl: choose the ultimate name = "menu" = "document ('../ menu.xml')" /> & Lt; Xsl: template match = "/" & gt;  

More valid and functional code followed by:

  & lt; Ul class = "menu_top" & gt; & Lt; Xsl: each selection = "$ menu" & gt; & Lt; Li & gt; & Lt; A & gt; & Lt; Xsl: attribute name = "href" & gt; # & Lt; Xsl: Select Value = "Link" /> & Lt; / XSL: Specialty & gt; & Lt; Xsl: Select the value = "name" /> & Lt; / A & gt; & Lt; / Li & gt; & Lt; / XSL: for-each & gt; & Lt; / Ul & gt; & Lt; Xsl: each selection = "$ menu" & gt; & Lt; Div class = "submenu" & gt; & Lt; Xsl: attribute name = "id" & gt; & Lt; Xsl: Select Value = "Link" /> & Lt; / XSL: Specialty & gt; & Lt; Ul & gt; & Lt; Xsl: each selection = "hair" & gt; & Lt; Li & gt; & Lt; A & gt; & Lt; Xsl: attribute name = "href" & gt; & Lt; Xsl: Select Value = "Link" /> & Lt; / XSL: Specialty & gt; & Lt; Xsl: Select the value = "name" /> & Lt; / A & gt; & Lt; / Li & gt; & Lt; / XSL: for-each & gt; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt; / XSL: for-each & gt;  

Finally my menu.xml:

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Menu & gt; & Lt; Category & gt; & Lt; Name & gt; First & lt; / Name & gt; & Lt; Link & gt; Menu-1 & lt; / Link & gt; & Lt; Children & gt; & Lt; Name & gt; Child 1 & lt; / Name & gt; & Lt; Link & gt; # & Lt; / Link & gt; & Lt; / Children & gt; & Lt; Children & gt; & Lt; Name & gt; Hair 2 & lt; / Name & gt; & Lt; Link & gt; # & Lt; / Link & gt; & Lt; / Children & gt; & Lt; / Category & gt; & Lt; / Menu & gt;  

I have more categories, but I have simplified it.

Thank you in advance!

document () function The origin of the document you are importing In this case, this is the menu element, not the class element. If you want to loop through categories, then use it instead:

  & lt; Xsl: each selection = "$ menu / menu / category" & gt; ...  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -