xml - Select only one node to be processed -


When I come to programming with xpath or xslt I am notibb. Im is just trying to try to process the specified node and in this process, make folders for each element. Here my test xml im is working:

XML:

  & lt; Sandbox & gt; & Lt; Unknown name = "unknown" & gt; & Lt; Property Name = "Unknow" Value = "Uncono" /> & Lt; / Unknown & gt; & Lt; See name = "object" & gt; & Lt; Element name = "first" value = "1" & gt; & Lt; Property Name = "Great" value = "10" /> & Lt; Element name = "detail" value = "3" & gt; & Lt; Property name = "luminous" value = "30" /> & Lt; Element name = "dot not" value = "0" & ​​gt; & Lt; Property name = "non" value = "0" /> & Lt; / Element & gt; & Lt; / Element & gt; & Lt; / Element & gt; & Lt; / View & gt; & Lt; See name = "Other object" & gt; & Lt; Element name = "seconds" value = "2" & gt; & Lt; Property Name = "More" Value = "20" /> & Lt; Element name = "detail" value = "4" & gt; & Lt; Property name = "dark" value = "40" /> & Lt; Element name = "dot not" value = "0" & ​​gt; & Lt; Property name = "non" value = "0" /> & Lt; / Element & gt; & Lt; / Element & gt; & Lt; / Element & gt; & Lt; / View & gt; & Lt; / Sandbox & gt;  

XSLT

  & lt; Xsl: stylesheet version = "2.0" xmlns: xsl = "http://www.w3.org/1999/XSL/conversion" & gt; & Lt; Xsl: strip-space element = "*" /> & Lt; Xsl: output omit-xml-declaration = "yes" indent = "yes" /> & Lt; Xsl: Template Match = "Sandbox / Watch [@ name = 'Other Object']" & gt; & Lt; Xsl: Apply-Select Template = "// Element" /> & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "element" & gt; & Lt; Xsl: result-document href = "{string-join (ancestors-or-self :: element, '/')} / {concat (@name, '_', condition ())} .xml" & gt; & Lt; Items & gt; & Lt; Xsl: copy-of select = "." / & Gt; & Lt; / Item & gt; & Lt; / XSL: Results-Documents & gt; & Lt; / XSL: Templates & gt;  

The output I want is the folder structure / object / first / extension. What am I doing wrong? I am getting an error that I can not create an output file. Do you have any advice on xpath cuz that my xpath does not correct me thanks

  & lt; Xsl: Template Match = "Sandbox / Watch [@ name = 'OtherObject']" & gt; & Lt; Xsl: Apply-Select Template = "// Element" /> & Lt; / XSL: Templates & gt;  

You probably want

  & lt; Xsl: template match = "/" & gt; & Lt; Xsl: select applicable-templates = "sandbox / view [@ name = 'other object'] // element" /> & Lt; / XSL: Templates & gt;  & lt; Xsl: result-document href = "{string-join (ancestors-or-self :: element, '/')} / {for concat (<)  

@name, _ ', Position ())} .xml "& gt; , please post the exact error message and tell us which folder name and which file name you want to create.

  & lt; Xsl: result-document href = "{string-join (ancestors-or-self :: element, '/')} / {concat (@name, '_', condition ())} .xml" & gt;  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -