Extraction of XPath selection results

Apr 14, 2010 at 3:01 PM

Hello again,

I brought up this discussion some time ago via the issue tracker.

I asked about a functionality to extract all nodes matching the XPath expression to e.g. paste them into new file via an editor, or to replace the current XML document by these selected nodes.

I just tested another XML related codeplex project named XML Explorer (http://xmlexplorer.codeplex.com) and it has such a functionality.
It opens just a new tab containing the selected nodes allowing to copy/cut/save them or to do a next XPath selection.

May be it could worth taking a look at this and to introduce this in the XPathVisualizer?

Thanks in advance for taking part within this discussion!

Best regards,

Martin Lemburg

Coordinator
Apr 14, 2010 at 7:09 PM

Yes, I remember you asked for this function, Martin.

I will take a look.   What version of XML Explorer includes this capability?  Do I need the .NET Framework 4.0? 

Also, don't take this the wrong way, but... I want to ask....   if XML Explorer does what you want.... , then why do you want the feature in XPathVisualizer?

Thanks,

-Dino

 

Coordinator
Apr 14, 2010 at 7:12 PM

ps: I really like the tabbed interfacte on XML Explorer - it looks very professional.

 

Apr 15, 2010 at 8:38 AM

Hello Cheeso,

I like small fingerprint of XPathVisualizer, which could be (not thinking of the dependencies to .NET) made "portable".

The XML Explorer was long time in a very "unstable" state! Now the version 4 is coming, not really bringing really new features, but a complete reworked UI and hopefully more stability!

So ... I have XPathVisualizer on my USB Stick to work with it, because it's handling is simple, the way to work with XPath results is easy, even if I have still thoughts for improvements.


Back to your question, if you need XML Explorer 4 with .NET 4 - I don't know, because I never looked it its sources, neither I asked the author.
But ... this feature is quit old, so I expect it should work with .NET 3.+ or even with .NET 2.

Perhabs you could ask him, - if the sources are not clean enough organized to see it.


Thanks for your engagement!

Best regards,

Martin

Coordinator
Apr 15, 2010 at 6:51 PM

Ah, I understand. 

Coordinator
Apr 19, 2010 at 2:16 PM

Hello, Martin,

I've updated XPathVisualizer with a new "Extract" capability.

Tell me what you think.  You need v1.2.1.0 to see it.

 

 

Apr 19, 2010 at 2:57 PM

Thanks Cheeso for implementing this new feature and the tabs!

Only "one" comment or suggestion - if attributes are selected via a XPath expression like "//@*[string-length() > 5]", than extracting this selection results will last in something not really usable - a simply concatenated string below the root node in this way:

    <root>attribute1Name="attribute1Value"attribute2Name="attribute2Value"...attributeNName="attributeNValue"</root>

Since XPathVisualizer does not handle attributes as nodes or objects while evaluating XPath expressions, why not handle them as nodes in an extraction result?

    <root><attribute1Name>attribute1Value</attribute1Name><attribute2Name>attribute2Value</attribute2Name>...<attributeNName>attributeNValue</attributeNName></root>

Or the original nodes are used:

    <root>
       <node1 attribute1Name="attribute1Value>...
       <node2 attribute2Name="attribute2Value" attribute3Name="attribute3Value">...
       ...

I think to select only attributes the first extraction would be the finest, because it will enable to handle the attributes as XML data.

What do you think?

Best regards,

Martin

Coordinator
Apr 19, 2010 at 3:15 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Apr 19, 2010 at 4:12 PM

Martin your idea sounds reasonable.

I put it into v1.2.1.1, which is now available.

There are still some gotchas - for example if you have an Xhtml file, and you extract, it's possible to have entity references in the extracted portion.  The DTD is not copied over to the extracted document, so those entities will be unknown, unless you manually add the XHTML DTD.