create XML using XPath and XSL
Hi,
I have map of xpath and corresponding text values.
So I want to use the xpath as key to get values from map and also use that xpath in node creation. Is there any API that I can use in Java to create nodes directly by passing xpath string?
like - domDoc.createElement(xPathString,value);
sample HashMap:
{
/rootNode/mainNode/element1 = "element1 text",
/rootNode/mainNode/element2 = " ",
/rootNode/mainNode/element2/element3 = "element3 text",
---and so on
}
After creating these elements I want to match them with XSL and output final XML document. So how this matching of Xptah in XSL could be done ?
The final output will be like:
<rootNode>
<mainNode>
<element1>element1 text </element1>
<element2>
<element3>element3 text</element3>
</element2>
</mainNode>
---- other mainNodes with different text values
</rootode>
Also there will be multiple mainNode s with different run time values for the elements.
Or is there a way to match XSL with Xpath and generate final elements as per XSL directly , instead of first creating them and again outputting in sequence specified in XSL.
Thank you.
|