I\'m trying to prototype a transform to turn xsl:schema into a php interface. I\'m having a little trouble matching xsd:simpleType elements that ha
The simpleType node is never selected because in the template where you match xsd:schema, you only apply the templates to the xsd:element child subtree. The xsd:simpleType sibling will never be processed.
If you want to allow the processing of all children of a node, you should include an empty inside the xsd:schema template.
That still won't generate the result you want. It's actually much simpler. To generate the code fragment you expect, you don't need to read the xsd:simpleType element, since the attribute that contains the type you want can be directly obtained from the @type attribute of xsd:element using xsd:value-of, and you can just print the $a immediately after it:
XmlString( $a)
Since you are generating text, you should use the elements to control how your whitespace will be distributed. For instance, if you use:
<?php
You won't need to worry about always placing the <?php text immediately after the and can indent your code normally. You can also include newlines with the
character (and it won't break your formatting):
interface FromXsd {
}
I edited your XSL and made these changes in the XSL document below:
<?php
interface FromXsd {
}
abstract public function build
XmlString(
$a
);
/*
*/
If you have an input such as:
This is a comment
It will produce the result below: