gnodet-bot commented on code in PR #27648:
URL: https://github.com/apache/camel/pull/27648#discussion_r4236657692


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/XmlChecks.java:
##########
@@ -187,4 +187,52 @@ public static List<String> validateXml(String content) {
         return msgs;
     }
 
+    private static final String XSL_NS = 
"http://www.w3.org/1999/XSL/Transform";;
+    /** A {...} in text that reads as an XPath expression: a function call, a 
path, an attribute or a variable. */
+    private static final Pattern LITERAL_BRACES = 
Pattern.compile("\\{([^{}\"']*(?:\\w\\(|/|@|\\$)[^{}\"']*)}");
+
+    /**
+     * Text in an element the stylesheet writes out (not inside an xsl: 
instruction) that holds a {expression}: in XSLT
+     * 1.0 and 2.0 an attribute value template is evaluated only in an 
attribute value, so in element content the braces
+     * and the expression are written as they are, with no error 
(CAMEL-25514). Not reported when the stylesheet turns
+     * on expand-text (XSLT 3.0), nor for braces around text with quotes (JSON 
written by the stylesheet).
+     */
+    static List<String> literalBraceNotes(String content) {
+        List<String> notes = new ArrayList<>();
+        if (content == null || content.isBlank() || 
content.contains("expand-text")) {

Review Comment:
   💡 **Nit:** `content.contains("expand-text")` is a raw string search over the 
entire document — a comment like `<!-- see expand-text docs -->` or an 
unrelated attribute would silently suppress all brace checks for the file. Per 
the Javadoc this is intentional: any mention of `expand-text` signals an XSLT 
3.0 stylesheet where text value templates are valid. Worth a one-line comment 
to that effect so a future contributor doesn't "fix" this to a DOM-level check 
without also updating `collectLiteralBraces` to handle per-element 
`xsl:expand-text` attributes:
   
   ```suggestion
           if (content == null || content.isBlank() || 
content.contains("expand-text")) {
               // coarse on purpose: any occurrence of expand-text signals XSLT 
3.0, where {expr} in element
               // content is valid (text value templates). A DOM-level 
refinement would also need to check
               // xsl:expand-text per-element inside collectLiteralBraces.
               return notes;
           }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to