-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Ability to apply XSL style sheet to Template #46
Comments
Could you have a sample for testing this feature ? |
Right now - no. I have something that works, but it can't be used as sample "as is". It requires some time to make a sample from that. You think it's necessary? |
We need to add unit tests to new features if we want to achieve a decent test coverage some day. Here is an example of a unit test I made for the Image Wrapping feature. https://github.com/PHPOffice/PHPWord/blob/master/test/PHPWord/Tests/ImageTest.php |
OK, guys. We'll see what I can do. Any guides, wishes, and recommendations on the tests are welcome. |
Guys, I'm stuck. AFAIK, samples are just samples. Samples live in "samples" folder, provide users with "how to" and they are not somehow connected with unit tests. On the other hand, unit tests is a different thing. Unit tests live in "test" folder. Do you want me to add something to the "samples" or to the "test" folder? |
@Progi1984 will have the last call on this but if I can had my 2 cents: Every feature that is added needs to have a unit test with it. The So to answer your question, I guess you could make a unit test and than add a little HOWTO in the README.md for using your feature. But wait for an answer by @Progi1984 . |
I'm ok with @gavroche. In Utopia, a good documentation would replace samples.
|
Why atoum and not PHPUnit? That would imply that developers have to learn a new Unit Test framework instead of using one that they already know. |
Oops... @gavroche, it's an error of my side, I discussed about atoum and unit tests with my wife while I writed my answer... It's not atoum for this project, but PHPUnit. |
Guys, could you please clarify why unit tests are organized in the way they are orginized now? I would like to suggest using an approach when "test" directory mirrors "Classes" directory (see here for details). On my mind such organization looks more clear. What do you think? |
@RomanSyroeshko I wait for @brunocasado (#22) before releasing PHPWord 0.7.0. In the next release (0.7.1), one of my goal is to implement unit tests in all the project (#43). So, at this moment, I will check an eye on all the code and the organization of the code. |
Okay, I will wait for 0.7.1 too then. It will be better to write unit tests once for correct organization of code than rewrite them several times. |
@RomanSyroeshko In the commit of yesterday night, I have moved the unit tests directory and put in place some tests. |
Roger that. |
@Progi1984, I'm done with that for now. There are 2 negative tests. To create positive test I need API from the PR #57 (issue #56). That PR/issue is planned for 0.7.2. So, please merge the tests "as is". I will create positive test later, in scope of the issue #56. As regards PR #57 (issue #56), there are two options. |
Merged in develop branch. |
I would like to use this feature (as it potentially may solve my need?) as the Template Processor can't handle what I need to do, which is beyond simple replacement, but I have no idea how this works?? It's not clear from the tests. An example in the sample code folder would be very useful IMHO |
Uhmm, the idea behind this feature is to allow advanced transformations of XML-based documents, more complex than regular string replacement. Think of it like of document structure transformation, not data transformation. For example, my document templates contain table templates. Each table template is represented by a header row and a data row template. So, I used XSL transformation to clone data rows before table population, and to remove unpopulated tables at the end. The code, which you already found among tests, will help you to understand how to actually call/run this feature. To understand what you can do with it and what you can't you should dive a little into XSL basics, and into your document format. The latter is important, because you can actually run XSL-transformation which will generate you a broken document, and it won't open. So, be careful. Good luck! |
Many thanks @syroeshko for your work and that incredibly quick response on this old thread! I'll give it a try, but my XSL knowledge needs some refreshing! For other reading this the test file and XSL files in question I believe are: https://github.com/PHPOffice/PHPWord/blob/develop/tests/PhpWord/TemplateProcessorTest.php |
Huh, XSL looks quite challenging for me too, each time. Stay strong! 😃 One important note here: use XSLT version 1.0. Those days XSLTProcessor wasn't able to support newer specifications. The same with XPath: stick with version 1.0. And yes, you found the right test file. Also there is passthrough.xsl, which does nothing useful I believe (it was long time ago ...). |
Sometimes we need to perform more complex actions with document template than just simple replace of ${} parameters. XSLT really helps in such situations.
This issue is a proposal of the correspondent class method implementation with the followed signature.
Assumption: we have XSL style sheet loaded as DOMDocument before the method call.
Requirement: "php_xml.dll" library.
Limitation: XSLT 1.0, XPath 1.0 (because of XSLTProcessor).
The text was updated successfully, but these errors were encountered: