ballsteve / xrust

XPath, XQuery, and XSLT for Rust
Apache License 2.0
84 stars 7 forks source link

Does xrust support namespace? #58

Closed ballsteve closed 4 months ago

ballsteve commented 11 months ago

Discussed in https://github.com/ballsteve/xrust/discussions/57

Originally posted by **tacoberu** October 21, 2023 Hello. I would like to use xrust in my library for xslt transformations. But somehow I can't force namespaces to be used on the output. Wouldn't there be a sample somewhere? Thanks for the direction.
tacoberu commented 10 months ago

In the attachment I attach what does not work for me.

I expect (Xalan xml/test2.xml xml/test2.xslt result):

<?xml version="1.0" encoding="utf-8"?>
<dat:dataPack xmlns:dat="http://www.stormware.cz/schema/version_2/data.xsd" xmlns:int="http://www.stormware.cz/schema/version_2/intDoc.xsd">
    <int:head>XSLT in Rust</int:head>
    <int:body>A simple document.</int:body>
</dat:dataPack>

But I only get:

<dataPack>
    <head>XSLT in Rust</head>
    <body>A simple document.</body>
</dataPack>

Thank you for answer.

Devasta commented 10 months ago

Apologies for the delay, looking into this now.

I can see the issues is twofold (based on branch InterP1, the upcoming release branch).

On the file xslt.rs, function to_transform(), we are not inlcuding namespaces.

Ok(Transform::LiteralElement(
        QualifiedName::new(None, None, a.to_string()),
        Box::new(Transform::SequenceItems(content)),
    ))

In addition, although namespace prefixes will appear if the above code is modified, the method to_xml() in the file intmuttree does not include namespace declarations.

@ballsteve I think we should try to get a fix for this into the next release.

ballsteve commented 10 months ago

Yes, this is a critical issue.

As a first step I'll make sure there is a test in the test suite for this issue.

As part of the release process, we'll make sure that all tests pass.

ballsteve commented 9 months ago

I've added a test for this issue on branch issue-58.

ballsteve commented 9 months ago

The test in branch issue-58 has been implemented and the test now passes. Once this branch has been merged the issue can be closed.

ballsteve commented 4 months ago

Latest release includes this fix