-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid attribute defaults being added #9
Comments
We cannot add an "sqf:copy-of" that will ignore the default attributes because the processing is done in XSL, and we cannot determine if an attribute is default or not in XSL.
And on the processing part we can generate a copy template that will ignore the specified attributes. Something like this:
|
Hi there, I don't think it is impossible to implement this, but I see much problems - so it won't be easy. @octavianN: I like your idea, but don't think that's enough. Because you would also delete all attributes with a specified value. We need a structure, which excludes attributes with a specified value. For instance like this:
But I think it is (almost) impossible to implement both - the sqf:copy-of in "XML save mode" and the except attribute. So both optional? Or another attribute like this:
The rule would be:
|
I think this feature is pretty important and I see it as a strength that SQF won't modify any content not effected by a fix. It surely should be possible to use the same concept to copy a part of it. I don't have sufficient insight into the implementation but I could imagine the following solutions:
|
In most cases you know the default attributes from your fix. So an "except" attribute will solve most of the problems. It can specify also the attributes values as in your example. For the "XML save mode" I see two solutions (but I do not like them):
|
I just committed an example/demonstration/experiment how you can copy content withouth attribute defaults and still use these attribute defaults for selection: https://github.com/schematron-quickfix/sqf/tree/master/samples/SqfUtil/sqfu-copy-of-test Thus, it would be possible to have a work-around based on XSLT. I'd still prefer if such a behavior could be built into the sqf:copy-of since I'm sure it could be integrated there even easier. I agree that this will be more processing but in my environment I can't imagine a situation where this will play a role - the quick fixes are always triggered by humans and it doesn't matter if he waits for 10 or 100ms. |
I agree that it is technically possible to implement this - but I guess if you want to take into account all possible edge cases, then this implementation becomes difficult - I am referring here to cases when you use external entities, XInclude either entire files or only fragments using different XPointer shemes, cases when the DTD defaults a namespace declaration and thus you select content in the XHTML namespace if default attributes are enabled but then you copy content in no namespace if you remove the attribute defaults, etc. Best Regards, |
I agree that this XSLT way is more a workaround than a solution - although it will most likely work for my personal use cases. On the other hand, while it is easy to implement excuding some attributes it makes the user interface pretty uncomfortable and in my environment there are several edge cases that could hardly be handled (e.g. haveing the same attribute with different default for different elements). However, keeping content unmodified appears to be a problem that you have already solved anyway: When you apply a quick fix e.g. by deleting a node the rest of the file won't be touched. So when you managed to identify a node to precisely remove it why is it so much more difficult to copy or keep it? Maybe the problem is that a select allows much more than a match attribute. Thus, an idea might be to get back to the sqf:keep element but with a match attribute that can only select content within the current context. |
I am not against this functionality but considering the implementation difficulties for edge cases, adding this feature to the language should be supported by a number of concrete use cases where just specifying some attributes to be excluded is not enough. From my experience DITA is probably one of the very few languages that is a little abusing the default attributes, but DITA cases are easily handled by specifying '@Class' and '@domains' to be excluded when copying content. |
Note that @Class and @donains are not the only attributes with default values. Another sample is @xml:space for the codeblock element. And there are few more (I just did a find-in-files in the schema). But more important (at least to me) are those attributes added or set to defaults by specialization. A simple sample would be to have @Audience been set to "internal" by default for a specialized section element that is meant to contain confidential data. I've just committed a simple sample "handle-dita-attributes" with 4 different quick fixes to play around. I'm planning to add additional samples:
|
Hi all, I'm sorry, but I'm a bit confused, what we are talking about. At the beginning I think there was four possible concepts for this issue:
Could you please specify which of those concepts you are prefering? To the discussion:
Do you mean "ignore default attributes" or "XML save mode"?
I was referring to "XML save mode". But I don't think there is a technical solution to copy nodes with all entities from one document to another (connected by XInclude or external entities). To the use cases:
But for the "ignore default attributes only" concept: yeah agree with @georgebina - there is not enough use cases. That's solvable with an except attribute.
So my proposal is:
I don't see a big problem in that. Because it is just a feature request. The implementation, which does not support the XML save mode, is still able to have an almost equal solution and wouldn't create corrupt files. Best Regards |
Personally I don't expect me using the except attribute. But I agree that it can be handy and it will be easy to implement. But I'm very interested in the "XML safe mode". I will explain a litle more how I think that it could be implemented:
There are probably still edge cases that result in broken xml but it would surly handle all of my own use-cases. |
For this issue "Avoid attribute defaults being added", I prefer the except attribute solution. Therefore we can define a mode for the sqf:copy-of element, maybe @unparsed-mode="true", that will copy without expanding the entities and XInclude and without copying the default attributes. |
I've just uploaded another sample with various attribute defaults. It's probably a very special case in global scope - but it's the main use-case for me personally. Just so you can understand why this is such an issue for me: However, I like the suggestion from Octavio to activate the unparsed mode by an attribute - just like @xml:space. |
When using xsl:copy-of within sch:add or sch:replace the attribute defaults will be added as well. This happens for instance on the new sample merge-dita-sl I just commited.
Maybe there could be a special behavior of sch:copy-of that it will copy the original code, not the one with resolved attribute defaults!?
The text was updated successfully, but these errors were encountered: